问题
Has anyone had trouble calling browser after executing the code mentioned below?
I have executed code from Pycharm version 2019.1 and I have done it from CMD but no results.
My Code:
import requests
import sys
import webbrowser as wb
import bs4
print ('Googling...')
res = requests.get('http://google.com/search?q='+''.join(sys.argv[1:]))
res.raise_for_status()
soup = bs4.BeautifulSoup(res.text, 'lxml')
linkElements = soup.select('.r a')
linkToOpen = min(5, len(linkElements))
for i in range(linkToOpen):
wb.open('http://google.com'+linkElements[i].get('href'))
No error messages, unable to call the browser.
来源:https://stackoverflow.com/questions/56542180/automate-the-boring-stuff-with-python-google-search-via-beautiful-soup-4