由于网站上有“显示更多”选项卡,Pandas无法读取网站上的所有表格

2024-05-16 20:16:02 发布

您现在位置:Python中文网/ 问答频道 /正文

所以这个网站我试图从中删除数据

nytimes.com/interactive/2020/us/coronavirus-us-cases.html

仅打印前9个状态,因为“显示更多”选项卡隐藏了更多表

import pandas as pd
tables = pd.read_html("nytimes.com/interactive/2020/us/coronavirus-us-cases.html")
print(Tables[0])

有没有办法让它打印出隐藏的表格?我一直在考虑使用selenium为我点击“显示更多”选项,但不确定这是否是一种有效的方法


Tags: 数据importcompandas网站状态htmlas