Google’s new AJAX API cracked
Following on from my last post, I just had a quick look at the data being transferred by Google’s AJAX search API. It’s really simple:
http://www.google.com/uds/GwebSearch? callback=f&context=0&lstkp=0& rsz=small&hl=en&q=YOUR_QUERY_HERE& key=internal-documentation&v=1.0
That returns a JavaScript expression of the form:
f('0', {results:[...]}, 200, null, 200)
To parse the results, just throw the second parameter of the function through a JSON parser.
Unfortunately, the Ruby JSON parser doesn’t like the non-string
hash keys (result
and so on) but it wouldn’t be a huge
effort to fix that.
Update: I’ve written a basic Ruby library. There are more details in the comments.