Monday, December 7, 2009

How to grab Google autocomplete list

We all know this wonderful feature:

Automation of grabbing that list can be helpful for instance if you want to know what people are looking for.

While typing in the search box, somewhere there is a Javascript code that makes the following HTTP GET request:
http://www.google.com/complete/search?hl=en&q=QUERY&cp=LEN(QUERY)

For example, the following query gives the same results as in the picture:
http://www.google.com/complete/search?hl=en&q=how%20to%20be%20better%20at%20&cp=20

window.google.ac.h(["how to be better at ",[
["how to be better at halo 3","43,100,000 results","0"],
["how to be better at basketball","87,500,000 results","1"],
["how to be better at math","52,900,000 results","2"],
["how to be better at soccer","88,300,000 results","3"],
["how to be better at football","207,000,000 results","4"],
["how to be better at beer pong","2,760,000 results","5"],
["how to be better at call of duty 4","72,600,000 results","6"],
["how to be better at madden","25,900,000 results","7"],
["how to be better at volleyball","9,370,000 results","8"],
["how to be better at chess","15,300,000 results","9"]]])

3 comments:

  1. Hi Yoni. Great info here. Do you happen to know the js code for the autocomplete on Google Product Search? The list is slightly different than what served through organic search.

    ReplyDelete
  2. add "&client=products" to the url

    ReplyDelete