我正尝试从挪威气象站打印出带有beautifulsoup的不同内容。 我设法打印出我想要的所有内容,但女巫却提到了下一小时的天气。
这包含我要获取的文本:
<span class="nowcast-description" data-reactid="59">har opphold nå,det holder seg tørt den neste timen</span>
我正在尝试用它打印它:
cond = soup.find(class_='nowcast-description').get_text()
Inspected elements from storm.no/ski
这是该网站上某些元素的图片。
打印这些:
soup = bs4.BeautifulSoup(html,"html.parser")
loc = soup.find(class_='info-text').get_text()
cond = soup.find(class_='nowcast-description').get_text()
temp = soup.find(class_='temperature').get_text()
wind = soup.find(class_='indicator wind').get_text()
也在此行中进行了测试:
cond = soup.select("span.nowcast-description")
但这给了我一切,除了我想要的东西。
我得到:
Ski Akershus,131英里。
“”
2°
3 m / s