【问题标题】:Error while using rjson package to retrive Yahoo's API Stock data使用 cjson 包检索 Yahoo API Stock 数据时出错
【发布时间】:2017-04-07 13:41:21
【问题描述】:

我正在尝试从 Yahoo 实时 API 获取 SPY 价格,该代码过去可以工作,但现在出现此错误(如下),我该如何克服这个问题

library(rjson)    
    json_file <- "http://finance.yahoo.com/webservice/v1/symbols/SPY/quote?format=json&view=detail"
    json_data <- fromJSON(paste(readLines(json_file), collapse=""))
    json_data

我收到此错误:

"Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open URL 'http://finance.yahoo.com/webservice/v1/symbols/AA/quote?format=json&view=detail': HTTP status was '406 Not Acceptable'

【问题讨论】:

  • 我得到了同样的错误。很可能他们已经从您上次运行代码时移动了 API 端点。我注意到有一个雅虎金融标签。你可能想在那里检查一下。

标签: r api yahoo yahoo-finance rjson


【解决方案1】:

您可以使用此 URL 作为替代。它下载 CSV 格式,但可以轻松解析。 http://download.finance.yahoo.com/d/quotes.csv?s=GOOG+APPL&f=nl1r

【讨论】:

    猜你喜欢
    • 2017-12-19
    • 2014-02-10
    • 2019-03-30
    • 2016-12-17
    • 1970-01-01
    • 2020-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多