问题
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 '.+'
回答1:
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.
来源:https://stackoverflow.com/questions/47026896/python-no-tables-found-matching-pattern