我正试图从参考资料中找出答案:https://www.baseball-reference.com/players/b/bondsba01.shtml
,而我想要的表是id=“batting_value”的表,但当我试图打印出我刮来的内容时,程序返回了一个空列表。如有任何信息或帮助,我们将不胜感激,谢谢!
from bs4 import BeautifulSoup
from urllib.request import urlopen
root_page = "https://www.baseball-reference.com/players/b/bondsba01.shtml"
soup = BeautifulSoup(urlopen(root_page), features = 'lxml')
table = soup.find('table', id = 'batting_value')
print(table)
我已经尝试打印id=“div_batting_value”的<div>,其中包含表,但仍然不起作用。然而,我可以成功地打印出具有不同id的其他<div>元素。