Jul-09-2019, 04:20 PM
Man, I'm having trouble with this project too. I'm getting no search results after passing the search terms into the run window. Here's my code:
#! python3 # lucky.py - Opens several Google search results. import webbrowser, bs4, requests, sys print('Googling...') # display text while downloading the Google page res = requests.get('http://google.com/search?q=' + ' '.join(sys.argv[1:])) print(res.raise_for_status()) # Retreive top search result links. soup = bs4.BeautifulSoup(res.text, "html.parser") # Open a browser tab for each result linkElems = soup.select('.r a') numOpen = min(5, len(linkElems)) for i in range(numOpen): webbrowser.open('http://google.com' + linkElems[i].get('href'))