Python:没有找到匹配模式“.+”的表

2024-06-06 07:47:52 发布

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

我要做的是将这个表导出为一个CSV格式,在一个Python脚本中,每一个页面有100行,但是在脚本下面遇到了这个错误。在

http://www.nhl.com/stats/player?aggregate=1&gameType=2&report=points&pos=S&reportType=game&startDate=2017-10-19&endDate=2017-10-29&filter=gamesPlayed,gte,1&sort=points,goals

import pandas as pd

dfs = pd.read_html('http://www.nhl.com/stats/player?aggregate=1&gameType=2&report=skatersummary&pos=S&reportType=game&startDate=2017-10-19&endDate=2017-10-29&filter=gamesPlayed,gte,1&sort=points,goals,assists')
df = pd.concat(dfs, ignore_index=True)
df.to_csv("1019_1029.csv", index=False)
print(df)

值错误:找不到匹配模式“.+”的表


Tags: posreport脚本comhttpdfwwwstats
1条回答
网友
1楼 · 发布于 2024-06-06 07:47:52

此网站无法使用pandas.read_html。 根据pandas documentation

This function searches for <table> elements and only for <tr> and <th> rows and <td> elements within each <tr> or <th> element in the table. <td> stands for “table data”.

但您尝试分析的站点使用<;div>;元素将数据结构化到表中: Source code of reffered page

因此,您将需要自定义解析解决方案来从该站点读取数据。在

相关问题 更多 >