Skip to content

Instantly share code, notes, and snippets.

@samrayner
Created August 28, 2012 10:43
Show Gist options
  • Save samrayner/3497098 to your computer and use it in GitHub Desktop.
Save samrayner/3497098 to your computer and use it in GitHub Desktop.
Get URL of top Google result for a query
api=http://ajax.googleapis.com/ajax/services/search/web?v=1.0
url=$(curl -s --get --data-urlencode "q=$1" $api |
sed 's|"unescapedUrl":"\([^"]*\).*|\1|;s|.*GwebSearch",||')
echo -n $url | pbcopy
echo $url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment