CroatiaHR
CroatiaHR

Reputation: 625

Passing a value to a search bar

I was trying to figure out a way to use the search bar of a web site without opening the webpage.

To be more precise, let us say we talk about stackoverflow.com. Using some GET operation it is possible to get the HTML content of it, and after looking it up to figure out that it has a search menu.

Is there a nice way to pass a value to the search menu, using some request!? My goal is to read the result of the search, again by asking for the HTML code.
I would prefer an idea in Python or JavaScript.

Upvotes: 0

Views: 299

Answers (1)

olinox14
olinox14

Reputation: 6663

There is not a general solution. Two things:

  • With python, you can use the requests lib to send your GET requests and get the response back. Then you will treat this response with the appropriate tool (response could be json, xml, html...)
  • To discover how to build your request, check if the website provide an documented API (example here with stackexchange). If it doesn't, try to use the inspector of your browser to discover how the search request is sent when you use the search-bar.

Upvotes: 2

Related Questions