Website Text Search with Android? - java

I'm trying to build an android app for fun, I am able to import the web search box into the app, but what I would like to do, is to have the search restricted to given website(s). So, I would like for the user to be able to enter a string into the text box, and for the search engine to search the given website(s), that is programmed into the script, and return posts associated with the string.
Can someone either explain or reference material the will explain how to do this, or at least give me the name of this process so I could do research myself?
Thank you in advance

If you're using the getStringExtra intent, then what you can do is you can store the search query in a String. Once you get this, you can use HttpGet() where you can specify the website you want to search along with the query.

I haven't done this in Android but if there is no other way in API, you can try to add a prefix to every search query such as "site:siteone.com || site:sitetwo.com " etc. this will force google to search only on siteone.com and sitetwo.com.
But I think there must be a better way.

Related

How about searching Google with Selenium?

I want to search something on Google using Selenium chromedriver and enter it. I can normally do this within the site, but I couldn't type it into google. What code can we use for this?
driver.findElement(By.xpath("//input[#class='desktopOldAutosuggestTheme-UyU36RyhCTcuRs_sXL9b']")).sendKeys("HBCV00000ODHHV");
Fakat olmadı.
The easiest way to do so is via the url when you perform driver.get(...).
Look at the google url for german shepards: https://www.google.com/search?q=german+shepards .
If you want to go the google.com and type in the search box you need to perform a better xpath query then by class name. As mentioned by #f1sh this is because google generates the class names (for scope based css). For me the following works for the search bar.
search_bar : WebElement = driver.get_element(By.XPATH, "//input[#title='Search']")
# then you can perform the send_keys
search_bar.send_keys(...)
Good Luck!
I think the problem is not the search text because I tried too many terms and it didn't work.
driver.findElement(By.xpath("//input[#class='desktopOldAutosuggestTheme-UyU36RyhCTcuRs_sXL9b']")).sendKeys("HBCV00000ODHHV");
 driver.findElement(By.xpath("//input[#class='desktopOldAutosuggestTheme-UyU36RyhCTcuRs_sXL9b']")).sendKeys(Keys.ENTER);
these are just an example on different sites. I tried id class type as xpath in every way, but it didn't write the text I wrote in the search bar.

get and display user location postcode in edittext on location button click like in just eat app

I am trying to do something like the picture below of just eat app using android studio. I am yet to start building my app but I would like to know how to implement getting user postcode and showing it in the edittext field. Any help will do.
![img1] https://drive.google.com/file/d/186D7fjSvJOhEQdep_fU4dnkUGV-Yi8Ya/view?usp=drivesdk
If you are looking to allow users to identify their post code from their address you might find the Post Office Adress File (PAF) useful although this is a paid for service.
https://en.wikipedia.org/wiki/Postcode_Address_File
https://www.royalmail.com/business/services/marketing/data-optimisation/paf
Some developers may be able to get free sample data for developing their application
https://www.poweredbypaf.com/access-to-free-paf-sample-data/
If you want to allow users to graphically find their postcode e.g. by clicking on a map you would need a map which returns a National Grid Reference and then use Codepoint data (https://digimap.edina.ac.uk/webhelp/os/data_information/os_products/supporting/codepoint_guidance.htm) which is also (an expensive) paid for service to find the nearest postcode co-ordinate using some data structure e.g. quadtree. This will not work correctly in all cases as post code boundaries are not always convex.
Hope that helps

Get TEXT only tweets using Twitter4j ? tweet that do not contain any media

There are a lot of forums asking to get medias from twitter but how to do the opposite? I want to get only the tweets which do not contain any image/video/url. If found those tweets just skip and search for the next because I want to display a full text without "http://t..." thing at the end. I put this in ...
cb.setIncludeEntitiesEnabled(false);
but, was not sure I did it right. Also, I write this code in Processing library but in Eclipse so I guess if you can show me the way in Java I will be fine, but a complete example please. I am very new to Java.
However, I have seen some people say about "filter=image" in tweet method but, I could not figure it out where to put this in. I have tried and fail.
Any suggestion? --Thanks in advance.
Stack Overflow isn't really designed for general "how do I do this" type questions. It's for specific "I tried X, expected Y, but got Z instead" type questions. Please try to be more specific. Saying "I could not figure it out where to put this in" doesn't really tell us anything. Where exactly did you try to put it? What exactly happened when you tried that? Can you please post a MCVE?
That being said, the best thing you can do is Google something like "twitter4j filter out images" or "twitter4j exclude images". More info:
Get Tweets with Pictures using twitter search api: Notice the second reply mentions the approach of getting all tweets and then manually checking whether it has an image. You could do the same thing to check that a tweet does not contain an image.
How to exclude retweets from my search query results Options: This mentions an exclude filter and a -filter that might be helpful.
Please try something and post a MCVE in a new question post if you get stuck. Good luck.

how to implement on android an interface to compose lucene query?

I have on my server a parser and a searcher for lucene query that search on xml and i have an android application that use this service.
Until now this android application has used the searcher in a simple way. Writing something on a text widget and clicking on a button it's like search:
title: something
It's found all the files which have on title "something".
But the service permit to me to search things like:
mediatype:audio AND mtime:[45dayago TO now] AND metadata_count:[04 TO 99]
More info on lucene query are here.
For user it's realy difficult know what terms are valid or how to describe advanced query but it's realy important to search on an archive. I would try to make an easy and valid lucene query to help the user to use that advanced search experience.
Any ideas would be appreciated.
If it were me, I'd start by constructing a view that has an arbitrary number of TextEdit boxes (the user can select how many, possibly via a spinner or a "add more" button). Then have a selector whether these terms are to be "ANDed" or "ORed" together.
Once you have that working, enhance each entry to be more than just a TextEdit, but to have options for entering numbers (via spinners?), ranges (via slider?) or dates/times (via a calendar picker?)?
The key here is to take an iterative approach. Implement one additional capability, and make sure it works, before moving on to the next one.

How to implement custom search on the server database in Android 2.3?

I have to implement custom search in my application for android 2.3.I have some EditText in which user type one letter and then I send response to the server, retrieve all the results matches this one letter and then I need to display them in a list. When user types second button I also need to send new response and refresh data and so on.
The question how can I do this in Android 2.3? What should i use?
This seems to be too open ended with too many questions to give a really helpful answer.
What you use in your app will heavily depend on how the server's API is expecting you to communicate. I, for one, am all for hiding the specifics of what a server does from the application and put all the "smarts" behind the API. So a query like:
http:/blah.com/getresults?search=a
would result in whatever matches 'a'. If it is searching a MySql Db, processing a Google search, or accessing files on the system doesn't matter.
Your code needs to worry about the interface to the API to make queries and processing the results, whether they're free formatted text, JSON objects, or whatever.
Maybe rewording your question or provide information on what you know would help.

Categories

Resources