Lri's answer only returns the last result for me, and I need 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
It is not as compact as we would like, but in a hurry.
katbyte
source share