我尝试使用BeautifulSoup从本网站获取表格:https://www.basketball-reference.com/players/b/bryanko01.html
我的代码如下:
f = open("testhtml.txt", 'w')
url = "https://www.basketball-reference.com/players/b/bryanko01.html"
html = urlopen(url)
bs = BeautifulSoup(html, "html5lib")
totals = [s.encode('utf-8') for s in bs.find_all("table")]
print(len(totals)) # prints 1
f.write(bs.prettify().encode('utf-8'))
f.close()
我写一个文件来查看原始html,并且有多个表(带有表标签),但出于某种原因,我对find_all("table")
的调用只返回一个表。
如果您对我可能做错了什么有任何疑问,请告诉我.f