Search code examples
google-search

Invoke google search via the address bar


Is it possible to invoke a Google search programatically ?

When I search for 'test' this is the URL generated : https://www.google.com/search?hl=en&newwindow=1&site=&source=hp&q=test&oq=test&gs_l=hp.3..0l2j0i20l2j0l6.1364.1718.0.1871.4.4.0.0.0.0.55.90.3.3.0.les%3B..0.0...1c.1.tNyGgn-NsNQ

But it seems I can reduce the URL without affecting search results so becomes

https://www.google.com/search?hl=en&newwindow=1&site=&source=hp&q=test

Which seems to produce the same result. I just want a way of invoking a search on the google site itself without typing in the search text box. The 'q' parameter seems to determine the search result, so I can just modify this parameter value on the address each time I want to search on google and search result will be the same as if typing the parameter into the Google home page search box ?


Solution

  • You can actually shorten it even further and just use:

    https://www.google.com/search?q=test
    

    The remaining parameters in the query indicate additional information about the source of the query that help Google understand its traffic sources. If this is just a simple tool that will save yourself some time, that should be fine, but be aware that doing things like this numerous times for scraping/other purposes will likely get you blocked (https://developers.google.com/errors/).