0
提取值我有一個網頁文件,它看起來像這樣: -如何從一類美麗的湯
<table class="table "><col width="75px"></col><col width="1px"></col><tbody><tr class="tablerow style2" prodid="143012"><td class="pricecell"><span class="WebRupee">Rs.</span>
29
<br/><font style="font-size:smaller;font-weight:normal">
3 days
</font></td><td class="spacer"></td><td class="detailcell"><span><span class="label label-default" style="background-color:#3cb521;color:#fff;border:1px solid #3cb521">FULL TT</span>
</span><span><span class="label label-default" style="background-color:#fff;color:#0c7abc;border:1px solid #0c7abc">SMS</span>
</span><div style="padding-top:5px">
29
Full Talktime
</div><div class="detailtext"> 5 Local A2A SMS valid for 1 day </div></td></tr><tr class="tablerow style2" prodid="127535"><td class="pricecell"><span class="WebRupee">Rs.</span>
59
<br/><font style="font-size:smaller;font-weight:normal">
7 days
</font></td><td class="spacer"></td><td class="detailcell"><span><span class="label label-default" style="background-color:#3cb521;color:#fff;border:1px solid #3cb521">FULL TT</span>
</span><span><span class="label label-default" style="background-color:#fff;color:#0c7abc;border:1px solid #0c7abc">SMS</span>
</span><div style="padding-top:5px">
59
Full Talktime
</div><div class="detailtext"> 10 A2A SMS valid for 2 days </div></td></tr><tr class="tablerow style2" prodid="143025"><td class="pricecell"><span class="WebRupee">Rs.</span>
99
<br/><font style="font-size:smaller;font-weight:normal">
12 days
</font></td><td class="spacer"></td><td class="detailcell"><span><span class="label label-default" style="background-color:#3cb521;color:#fff;border:1px solid #3cb521">FULL TT</span>
</span><div style="padding-top:5px">
99
Full Talktime
</div><div class="detailtext"> 10 Local A2A SMS for 2 days only </div>
I want the values 29, 3 days,29 full talktime, 59, 7 days,59 full talktime etc.
,但我得到了整個文檔,如果我嘗試在腳本下面。
from bs4 import BeautifulSoup
import requests
r = requests.get("http://www.ireff.in/plans/airtel/karnataka")
data = r.text
soup = BeautifulSoup(data,"html.parser")
table = soup.find('table',{'class':'table'})
print(table)
我在哪裏出錯了? 我想獲得這些值具體。
或者如果表可以轉換爲json數組,那也是有幫助的。
的findall不存在,它的findAll,如果使用的findAll,腳本不起作用,此代碼的工作,請給我一些時間來接受答案 – penta