It\'s relatively easy to parse the output of the AJAX API using a scripting language:
#!/usr/bin/env python
import urllib
import json
base = \'http://ajax.goog
Lri's answer only returned the last result for me and i needed the top so I changed it to:
JSON=$(curl -s --get --data-urlencode "q=QUERY STRING HERE" http://ajax.googleapis.com/ajax/services/search/web?v=1.0 | python -mjson.tool)
response=$(echo "$JSON" | sed -n -e 's/^.*responseStatus\": //p')
if [ $response -eq 200 ] ; then
url=$(echo "$JSON" | egrep "unescapedUrl" | sed -e '1!d' -e "s/^.*unescapedUrl\": \"//" -e "s/\".*$//")
echo "Success! [$url]"
wget $url;
else
echo "FAILED! [$response]"
fi
Its not as compact as I'd like but in a rush.