首页 > 解决方案 > Use python requests to download csv file

问题描述

I am wanting to create a program that can run either weekly or daily to scrape data from a website and download the data in csv format. I was wondering if this was possible to use with Python because that is my preferred application to use, if at all possible how do you suggest I go about it. The website I am wanting to use is: https://finance.yahoo.com/ with the (S&P 500) data. Thank you!

标签: csvweb-scrapingpython-requests

解决方案


目前尚不清楚您希望将哪个表转换为 csv。雅虎不会阻止请求。

如果您对 pandas 有所了解:

df = pd.read_html('https://finance.yahoo.com/quote/%5EGSPC?p=^GSPC')[0]
df.to_csv('df.csv', index=False)

推荐阅读