Created
August 28, 2012 10:43
-
-
Save samrayner/3497098 to your computer and use it in GitHub Desktop.
Get URL of top Google result for a query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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