python bs4刮表得到错误的结果
我正在努力清理这个网站:并得到底部的表格。当我试图刮去它时,我得到了第一行的一些元素,但没有从表的其余部分得到任何东西。这是我的密码python bs4刮表得到错误的结果,python,beautifulsoup,Python,Beautifulsoup,我正在努力清理这个网站:并得到底部的表格。当我试图刮去它时,我得到了第一行的一些元素,但没有从表的其余部分得到任何东西。这是我的密码 urlText = "http://stcw.marina.gov.ph/find/?c_n=14-111112&opt=stcw" url = urlopen(urlText) soup = bs.BeautifulSoup(url,"html.parser") certificates = soup.find('table',class_='table
urlText = "http://stcw.marina.gov.ph/find/?c_n=14-111112&opt=stcw"
url = urlopen(urlText)
soup = bs.BeautifulSoup(url,"html.parser")
certificates = soup.find('table',class_='table table-bordered')
for row in certificates.find_all('tr'):
for td in row.find_all('td'):
print td.text
我得到的输出是:
22-20353
SHIP SECURITY OFFICER
而不是整张桌子。
我错过了什么?这又是一个例子。切换到
lxml
或html5lib
查看解析的完整表格:
soup = bs.BeautifulSoup(url, "lxml")
soup = bs.BeautifulSoup(url, "html5lib")