![](/img/trans.png)
[英]Web scraping with BeautifulSoup - when trying to find table the content is not returned
[英]Can't find table when scraping with beautifulsoup
我有
r = requests.get("https://baseballsavant.mlb.com/leaderboard/custom?year=2021&type=batter&filter=&sort=5&sortDir=desc&min=q&selections=r_total_stolen_base,sprint_speed,&chart=false&x=r_total_stolen_base&y=r_total_stolen_base&r=no&chartType=beeswarm")
soup = BeautifulSoup(r.content, "html.parser")
table = soup.find("tbody")
print(table)
它返回None
,即使显然有一个表标签
您的sort
URL 参数设置为5
(第五列),但查询选择仅返回 3 列,因此访问该 URL 时没有显示表。
尝试将?sort=
设置为0
、 1
、 2
或3
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.