【发布时间】:2018-10-03 04:24:45
【问题描述】:
我正在尝试从this 中抓取一张桌子 网页。
到目前为止,我可以访问该页面,使用 mechanize 单击搜索按钮,但是当我开始使用 beautifulsoup 解析 html 时遇到问题。我的代码是:
url = 'http://forestsclearance.nic.in/Wildnew_Online_Status_New.aspx'
br = mechanize.Browser()
br.open(url)
br.select_form(name='aspnetForm')
page = br.submit(id='ctl00_ContentPlaceHolder1_Button1')
soup = BeautifulSoup(page, 'html.parser')
table = soup.findAll("table", {"id" : "ctl00_ContentPlaceHolder1_tbl"})
print table
如果您查看 HTML,我想要的表在字典中有 id,但这只会打印第一行的 html。我尝试使用 findChildren() 找到 div 标签,但它总是返回第一行。有人知道为什么会发生这种情况以及我如何抓住整张桌子吗?谢谢
【问题讨论】:
标签: python beautifulsoup