我正在制作一个基本的“我感觉很幸运”Python应用程序,但是当我尝试选择链接时,它什么也不返回
import requests, webbrowser, bs4, sys
print('Googling...')
res = requests.get('https://google.com/search?q=%s' % sys.argv[1])
if res.status_code != 200:
print('Invalid input')
sys.exit()
res = res.text
soup = bs4.BeautifulSoup(res, features='html.parser')
search = soup.select('.r') # trying to select the class "r"
print(search) # returns "[]"
这是因为谷歌发送的是重定向页面,而不是结果页面。这会阻止系统工作
相关问题 更多 >
编程相关推荐