此Python脚本的页面爬网

此Python脚本的页面爬网,python,web-crawler,Python,Web Crawler,我试图一次抓取1-17页。当我运行此程序时,虽然我所在的链接是“全部”,但它仍然只能爬行第1页。我想要1-17个都在同一个csv上。有什么建议吗?如果您查看页面源代码(右键单击页面并在google chrome中点击inspect If)您将看到“所有”页面的实际链接是https://www.cbssports.com/nhl/stats/playersort/nhl/year-2017-season-preseason-category-goals?print_rows=9999如下图中突出显

我试图一次抓取1-17页。当我运行此程序时,虽然我所在的链接是“全部”,但它仍然只能爬行第1页。我想要1-17个都在同一个csv上。有什么建议吗?

如果您查看页面源代码(右键单击页面并在google chrome中点击inspect If)您将看到“所有”页面的实际链接是
https://www.cbssports.com/nhl/stats/playersort/nhl/year-2017-season-preseason-category-goals?print_rows=9999
如下图中突出显示的行所示


如果您查看页面源代码(右键单击页面并在google chrome中点击inspect If),您将看到“ALL”页面的实际链接是
https://www.cbssports.com/nhl/stats/playersort/nhl/year-2017-season-preseason-category-goals?print_rows=9999
如下图中突出显示的行所示

import pandas as pd

dfs = pd.read_html('https://www.cbssports.com/nhl/stats/playersort/nhl/year-2017-season-preseason-category-goals')
df = pd.concat(dfs, ignore_index=True)
df.to_csv("20172018PreseasonData.csv", index=False)
print(df)