【发布时间】:2021-02-21 09:18:18
【问题描述】:
我要解析的这个页面 - https://fbref.com/en/comps/9/gca/Premier-League-Stats
它有 2 个表,我试图从第二个表中获取信息,但每次运行此代码时它都会显示第一个表。
from bs4 import BeautifulSoup
import requests
source = requests.get('https://fbref.com/en/comps/9/gca/Premier-League-Stats').text
soup = BeautifulSoup(source, 'lxml')
stattable = soup.find('table', class_= 'min_width sortable stats_table min_width shade_zero')[1]
print(stattable)
min_width sortable stats_table min_width shade_zero 是'second'表的ID。
它不会给我一个错误,也不会返回任何东西。它是空的。
【问题讨论】:
标签: python html matplotlib beautifulsoup data-science