【问题标题】:Error when trying to connect to google finance Python尝试连接到 Google Finance Python 时出错
【发布时间】:2017-11-09 06:11:11
【问题描述】:

我可以使用 datareader 连接到 yahoo Finance,但在连接到其他 API(例如 google Finance)时遇到问题,我无法弄清楚原因。

我正在使用以下代码:

import pandas_datareader.data as web
import datetime
start = datetime.datetime(2017, 9, 27)
end = datetime.datetime(2017, 11, 7)
f = web.DataReader('F', 'google', start, end)
f.ix['2017-11-04']

并得到以下错误信息:

RemoteDataError:无法读取 URL:http://www.google.com/finance/historical?q=F&startdate=Sep+27%2C+2017&enddate=Nov+07%2C+2017&output=csv

任何建议都会有所帮助,因为我在网上找不到任何关于此的内容。

【问题讨论】:

    标签: python pandas-datareader


    【解决方案1】:

    如果您打开 csv 文件,您将看到“2017-11-04”没有数据,因此出现错误。

    这些代码适用于另一个日期,例如 csv 中的“2017-11-03”。这是输出:

    Open            12.41
    High            12.46
    Low             12.32
    Close           12.36
    Volume    33220261.00
    Name: 2017-11-03 00:00:00, dtype: float64
    

    Google Finance API 并非每天都覆盖。它经常错过一两天。

    【讨论】:

    • @YingSquared- 我试过了,但我仍然收到相同的错误消息。当我复制并粘贴 URL,生成 excel 文件并打开它时,数据就在那里,但 python 似乎无法读取 URL。 raise RemoteDataError('Unable to read URL: {0}'.format(url)) RemoteDataError: Unable to read URL: google.com/finance/…
    猜你喜欢
    • 2023-03-11
    • 2020-09-01
    • 2014-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多