Reputation: 1
I want to make an app that asks the user for an input and then it'll search a website and have it display the results.
I know I'm gonna have to do some web scraping to make the app display the results but the thing I'm stuck on is how to do the searching. I want it to be as if the user is using the search function on the website itself. For example, if a user types into the app's search bar "chairs", the app would show wikipedia's results for "chairs"
Upvotes: 0
Views: 135
Reputation: 18301
Using your Wikipedia example, it's fairly straight forwards. You send a GET request to the Wikipedia site, and it will return the correct page. GET requests use parameters appended to the end of the URL, so take
en.wikipedia.org/w/index.php?search=
And append your query chairs
and you get http://en.wikipedia.org/w/index.php?search=chairs
With Wikipedia, you need to replace the spaces with a + symbol. So if you wanted to search for Musical Chairs
, it would be
en.wikipedia.org/w/index.php?search=Musical+Chairs
The URL will be different for each site, but it should be fairly easy to find it if you look at the html, or even looking at the URL in your browser after you search on the site
Upvotes: 1