csv - 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!
解决方案
目前尚不清楚您希望将哪个表转换为 csv。雅虎不会阻止请求。
如果您对 pandas 有所了解:
df = pd.read_html('https://finance.yahoo.com/quote/%5EGSPC?p=^GSPC')[0]
df.to_csv('df.csv', index=False)
推荐阅读
- generator - Lambda Prolog 中的列表理解
- python - 使用 Asyncio 和 Aiohttp 下载数千张图片
- x86 - 在 AVX(及更高版本)中打包非连续向量元素
- python - 如何在 tfp.layers.DistributionLambda 中实例化包含变量的分布
- image - 在 Xamarin Forms 中加载图像时的回调
- python - Python - 如何获取有关 SyntaxError 的更多信息?
- pandas - 我得到 ValueError:一个系列的真值是不明确的。使用 a.empty、a.bool()、a.item()、a.any() 或 a.all()。使用熊猫
- php - 尝试使用 PHP 连接到 MySQL 时出错
- gatsby - 如何从 Image URl Gatsby 中删除哈希
- java - 有没有办法使用二进制搜索来获得特定的结果