Created
September 18, 2019 15:23
-
-
Save powerexploit/a5c184c5927b3a005163f9387e4bf00c to your computer and use it in GitHub Desktop.
Google Search Result Scraper
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
#!/usr/bin/python3 | |
# Pygoogle.py -> Opens several Google search results | |
import sys | |
import requests | |
import webbrowser | |
import bs4 | |
print('Googling') | |
res = requests.get('http://google.com/search?q=' + ' '.join(sys.argv[1:])) | |
res.raise_for_status() | |
#Retrive top search result links. | |
#Open a browser tab for each result. | |
#Retrive top search result links. | |
mysoup = bs4.BeautifulSoup(res.text,"html.parser") | |
# Open a browser tab for each result. | |
link = mysoup.select('.r a') | |
numOpen = min(5,len(link)) | |
# | |
for i in range(numOpen): | |
webbrowser.open('http://google.com' + link[i].get('href')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment