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:
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.
See also Google’s AdWords keyword suggestion tool:
https://adwords.google.com/select/main?cmd=KeywordSandbox
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
It doesn’t work with meta-keywords like “site:domain.tld”. Too bad, you could use it as a search engine for your own site otherwise.
I wrote Python module.
http://tokuhirom.dnsalias.org/~tokuhirom/wiki/PyGoogleSuggest_2den
How long will it take to embed it into Mozilla / Firefox search plugin? Hmm… $5 to the first to do so.
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.
A Firefox module that auto-completes using this would be extraordinarily cool.
a nice library that allows you to do the same stuff (using a php backend) http://jpspan.sourceforge.net
fe this demo http://jpspan.sourceforge.net/examples/autocomplete.php
They already have a firefox extension for this! Check it out: http://www.loconet.ca . It has some issues but not bad for a night of hacking.
I second the Firefox/Mozilla auto-complete search box.
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.
Great Article.
BUT, Do you have an explanation for VB (ASP)?
Would be appriciate.
Thanks!
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.
Pingback: Koldark's Komputer World
Pingback: blog.bulknews.net
Pingback: Nick Bradbury
Pingback: Preoccupations
Pingback: A Day After Yesterday
Pingback: Silicon Barista
Pingback: bulknews.typepad.com
Pingback: ad Weblog
Pingback: VagueWare.com
Pingback: Erik Benson's Morale-O-Meter
Pingback: Gautam Guliani's home on the web
Pingback: Tim Haines
Pingback: Tim Haines
Pingback: Alex Barnett blog
Pingback: Textiplication
Pingback: Journal
Pingback: Magic Bean Dip
Pingback: cogdogblog
Pingback: line of site
Pingback: Kemayo
Pingback: Weblog Zonder Haast
Pingback: Utsikt från en etta i Ronneby
Pingback: Ekkie movin' on...
Pingback: Craig's Manila Test Site
Pingback: IO
Pingback: IO
Pingback: Anonymous
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.
-nobodyz
I like how when you type “tay” it automatically suggests Taylor Rain! Those google guys are thinking on the right level.
Great Post. Very helpfull informations. Thanks a lot. Jürgen from Germany.