Last active
December 28, 2021 16:41
-
-
Save stuart-warren/6072885ce4e96bb9731fe57345496363 to your computer and use it in GitHub Desktop.
search google from terminal
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
# get back a list of urls for search term | |
# $ goog stuart-warren github | |
# $ goog site:stackoverflow.com ValueError | |
goog() { | |
# uses https://github.com/mgdm/htmlq | |
query=${@} | |
v="" | |
if [[ "$1" == "-v" ]]; then v="-v"; fi | |
curl ${v} -LG --data-urlencode "q=${query}" \ | |
--data-urlencode "sourceid=chrome" \ | |
-H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" \ | |
https://google.com/search -s | htmlq div.g a -a href | grep -vE '^#|^/|googleusercontent' | sort -u | |
} | |
# $ stackoverflow ValueError | xargs open | |
alias stackoverflow="goog site:stackoverflow.com" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment