Python:找不到与模式“.+"匹配的表 [英] Python: No tables found matching pattern '.+'

查看:100
本文介绍了Python:找不到与模式“.+"匹配的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做的就是将此表导出为CSV格式,用于在Python脚本中每个100行的所有7页,但是在脚本下方却遇到此错误.

"

因此,您将需要自定义解析解决方案才能从该站点读取数据.

I am trying to do is export this table as a CSV for all 7 pages of 100 rows each within a Python script but an running into this error below the script.

"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)

ValueError: No tables found matching pattern '.+'

解决方案

This site wont work with pandas.read_html. According to 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".

But site you are trying to parse uses <div> elements for structuring data into the table:

Hence, you will need custom parsing solution to read data from this site.

这篇关于Python:找不到与模式“.+"匹配的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆