我建议改用API,因为这些API是为与应用程序交互而设计的。如果您尝试以编程方式访问搜索结果,并要求您填写验证码以证明自己是人,则Google可能会对此表示怀疑。
除此之外,这是您的操作方法:
requests
例如:
from bs4 import BeautifulSoup
import requests
url = 'https://www.accuweather.com/en/no/oslo/254946/current-weather/254946'
r = requests.get(url) # get the page content using requests
soup = BeautifulSoup(r, 'html.parser') # parse the page HTML
current_temp = soup.select('.display-temp').get_text() # locate the element of interest, and get the element's text content
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句