【发布时间】:2022-02-08 05:36:23
【问题描述】:
当我从网站上抓取表格时,它缺少底部 5 行数据,我不知道如何提取它们。我正在使用 BeautifulSoup 和 Selenium 的组合。我以为它们没有加载,所以我尝试使用 Selenium 滚动到底部,但这仍然不起作用。
代码试验:
site = 'https://fbref.com//en/comps/15/10733/schedule/2020-2021-League-One'
PATH = my_path
driver = webdriver.Chrome(PATH)
driver.get(site)
webpage = bs.BeautifulSoup(driver.page_source, features='html.parser')
table = webpage.find('table', {'class': 'stats_table sortable min_width now_sortable'})
print(table.prettify())
df = pd.read_html(str(table))[0]
print(df.tail())
请你帮忙刮一下整张桌子吗?
【问题讨论】:
-
这里不需要使用 selenium,使用
requests就足够了,而且速度更快。该表未动态加载。
标签: python pandas dataframe selenium beautifulsoup