以下代码按预期工作。它返回7行。你知道吗
from bs4 import BeautifulSoup
import urllib2
url="http://www.findandtrace.com/trace-mobile-number-location?mobilenumber=9834900000&submit=Trace"
page=urllib2.urlopen(url)
soup = BeautifulSoup(page.read())
universities=soup.findAll('b')
for eachuniversity in universities:
print eachuniversity.string
但我只需要第三和第四条线。你知道吗
9834900000
9834900000
MADHYA PRADESH & CHHATISGARH
AIRTEL
GSM
LIVE - Active
Mobile Reputation & Monitoring
预期输出为元组:
('MADHYA PRADESH&CHHATISGARH','AIRTEL')
我如何达到这个结果?你知道吗
与其查找粗体标记,不如查找表并解析出行:
这将产生:
允许您按键而不是索引提取所需的数据:
相关问题 更多 >
编程相关推荐