我想知道为什么我不能使用这个功能?
问题描述:
yahoo<-function(sym,current = TRUE, a=0,b=1,c=2000,d,e,f,g="d")
{
if(current){
f<-as.numeric(substr(as.character(Sys.time()),start = 1,stop = 4))
d<-as.numeric(substr(as.character(Sys.time()),start = 6,stop = 7))-1
e<-as.numeric(substr(as.character(Sys.time()),start = 9,stop = 10))
}
require(data.table)
tryCatch(
suppressWarnings(
fread(paste0("http://ichart.yahoo.com/table.csv",
"?s=",sym,
"&a=",a,
"&b=",b,
"&c=",c,
"&d=",d,
"&e=",e,
"&f=",f,
"&g=",g,
"&ignore=.csv"),sep=",")),
error = function(e) NULL
)
}
当我运行谷歌< -yahoo( “GOOG”),这是我收到的消息:我想知道为什么我不能使用这个功能?
试图URL 'http://ichart.yahoo.com/table.csv?s=GOOG&a=0&b=1&c=2000&d=8&e=13&f=2017&g=d&ignore=.csv' 内容类型“text/html的; charset = utf-8'length unknown 已下载1078字节
那么如何更改该功能使其工作?
答
此代码不工作,因为the Yahoo Finance web service which you're trying to access was discontinued in May 2017。您需要为这些数据找到其他来源。
这是什么语言?请编辑您的问题,将其作为标签加入。 –
这似乎是R.这个函数有什么问题?你得到了1078个字节,这是不是预期的? – Stefan