我正在通过https://www.wunderground.com/获取基本天气数据(如每日高/低温)来 搜索网页图谱(搜索随机邮政编码).
我已经尝试了我的代码的各种变体,但它不断返回一个温度应该是的空列表.老实说,我只是不知道自己哪里出错了.谁能指出我正确的方向?
import requests
from bs4 import BeautifulSoup
response=requests.get('https://www.wunderground.com/cgi-bin/findweather/getForecast?query=76502')
response_data = BeautifulSoup(response.content, 'html.parser')
results=response_data.select("strong.high")
Run Code Online (Sandbox Code Playgroud)
我还尝试了以下各种其他变体:
results = response_data.find_all('strong', class_ = 'high')
results = response_data.select('div.small_6 columns > strong.high' )
Run Code Online (Sandbox Code Playgroud)