抓取網站溫度資訊
weather_wd=soup.findAll('div',{'class':"wdtemp"})
print(weather_wd)
輸出結果
[<div class="wdtemp">
<span class="tred">11</span> ~ <span class="tblue">13 </span>
</div>]
想要輸出結果如下:
11 ~ 16
求指教不帶標簽的結果要如何改
uj5u.com熱心網友回復:
"<.*?>\d+?<.*?>"uj5u.com熱心網友回復:
新手想的個笨辦法
抓取網站溫度資訊
weather_wd=soup.findAll('div',{'class':"wdtemp"})
對weather_wd結果二次匹配:
ma1 = re.findall('\d+', weather_wd)
print(ma1[0], ' ~ ', ma1[1])
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/128802.html
上一篇:藍橋杯 基礎訓練 回文數
