希望得到一些帮助,我需要废弃id和温度。我尝试了几件事,但我无法做到可以有人帮忙。我正在使用BeautifulSoup获取信息然后打印出来
<span id="root.content.BoundLabel12.text">21.1 ºC</span>
答案 0 :(得分:0)
>>> from bs4 import BeautifulSoup
...
... soup = BeautifulSoup(
... '<span id="root.content.BoundLabel12.text">21.1 ºC</span>'
... )
>>> span_id = soup.span['id']
>>> span_id
'root.content.BoundLabel12.text'
>>> temperature = soup.span.text
>>> temperature
'21.1 ºC'