Created
January 25, 2019 18:54
-
-
Save rounakdatta/0d4e34b92c7fc6084002db47531e71d5 to your computer and use it in GitHub Desktop.
Get Me those Google links
This file contains hidden or 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
import requests | |
from bs4 import BeautifulSoup | |
def google_search(uri): | |
raw_result = requests.get(uri) | |
soup = BeautifulSoup(raw_result.content) | |
for a in soup.find_all('a', href=True): | |
if a['href'].startswith('/url?q=') and 'webcache.googleusercontent' not in a['href']: | |
print(a['href'][7:].split('&sa')[0]) | |
query = 'tensorflow install error' | |
google_search('https://www.google.com/search?q=' + query) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment