Hacking Google Suggest

Google’s Suggest feature is lighting up the blogosphere these days. It functions as like autocomplete for your search box, where Google attempts to determine what you are searching for and gives you suggestions. Web tinkerer that I am, I had to dig in a little and see how this works.

At its simplest, Google Suggest is javascript code that looks at what you are typing in the Google search box. When you press a key, GS phones home and passes the current contents of the search box. The server returns some suggestions are then displayed to the user. The javascript code is a little obfuscated, more to keep the size down than to obscure the contents. You can look at it here.

The script handles the onkeydown event of the search box. When that fires, it grabs the contents of the search box and sends the contents to a Google server for suggestions.

A request to the suggestion server looks like this:

In return, the suggestion server returns some results as javascript. Here are the results that get returned when I have typed "netcaptor" in the box:

sendRPCDone(frameElement, "netcaptor", new Array("netcaptor", "netcaptor 7.5.3 crack", "netcaptor download", "netcaptor 7.5.3", "netcaptor crack", "netcaptor pro", "netcaptor 7.5.2", "netcaptor 7.5.3 serial", "netcaptor v7.5.3", "netcaptor review"), new Array("141,000 results", "169 results", "68,300 results", "2,890 results", "8,360 results", "56,500 results", "2,390 results", "213 results", "281 results", "15,900 results"), new Array(""));

Cool, huh?

Hacked appropriately, this could be a cool tool for generating related searches to a given keyword. Here’s a quick, first attempt – I put together some sample code that grabs Google’s suggestion for a given keyword (or partial). GPL’ed PHP source code is included.

Oh yeah – you might be interested in my earlier post about hacking Adsense for Feeds.


43 thoughts on “Hacking Google Suggest

  1. it works nice 🙂

    but it has make me thinking… pushing technology like this too far could bring us a less “free” search experience. to try to make you thinking in this direction i will give a more extrem exsample. lets say i would search for nana, and the search engen would say “lets search for banana, i have a lot of links for banana” 🙂

    search engens could get worse because most of people would search the suggested keywords (for wich the search engen has or should had good results), but nobody would try to find some new, unexplored secrets of the web…

    regards, saso 🙂

  2. Hmmm… just wondering if this violates Google’s terms of service re scraping? Should it use the API?
    Possibly its violating the letter, but not the spirit, as its only doing a single search per query? I haven’t read them in ages.

  3. I’d like to see more information about how to perform HTTP GETs from the various browsers and parse/display the results in the browser. There seems to be a distinct dearth of informationabout how to do this.

  4. Good article. Wanted to let you know that we recently created a proof-of-concept app at ajaxed.com that allows users to add keyword autosuggest capability (similar to Google Suggest) to their website without any custom programming. We’d appreciate any feedback you can provide.

  5. Pingback: Koldark's Komputer World

  6. Pingback: blog.bulknews.net

  7. Pingback: Nick Bradbury

  8. Pingback: Preoccupations

  9. Pingback: A Day After Yesterday

  10. Pingback: Silicon Barista

  11. Pingback: bulknews.typepad.com

  12. Pingback: ad Weblog

  13. Pingback: VagueWare.com

  14. Pingback: Erik Benson's Morale-O-Meter

  15. Pingback: Gautam Guliani's home on the web

  16. Pingback: Tim Haines

  17. Pingback: Tim Haines

  18. Pingback: Alex Barnett blog

  19. Pingback: Textiplication

  20. Pingback: Journal

  21. Pingback: Magic Bean Dip

  22. Pingback: cogdogblog

  23. Pingback: line of site

  24. Pingback: Kemayo

  25. Pingback: Weblog Zonder Haast

  26. Pingback: Utsikt från en etta i Ronneby

  27. Pingback: Ekkie movin' on...

  28. Pingback: Craig's Manila Test Site

  29. Pingback: IO

  30. Pingback: IO

  31. Pingback: Anonymous

  32. saso badovinac said,


    That’s what I’m saying! I immediately was intensely ANNOYED at this “google suggest” garbage. I want to search for what I want to search for — not what 40 million other people searched for.

    I am not happy when someone or someplace attempts to steal my freedom to think for myself. I’m sorry that other people never learned how to spell, but that’s not MY problem. Damn! Get a dictionary and learn, folks. This “the web will think for you, spell for you, entertain you” attitude with the latest technology is going too far if you ask me. “User friendly” has overreached its grasp.


  33. I like how when you type “tay” it automatically suggests Taylor Rain! Those google guys are thinking on the right level.

Comments are closed.