download.file仅适用于https

时间:2016-10-20 16:32:21

标签: r quantmod

我有一个奇怪的问题。我使用quantmod包来从“oanda”提供商处获得费率。它在内部使用download.file函数,该函数失败并带有消息

  

无法打开网址“http://www.oanda.com/ .....”

我能够将问题缩小到:

> download.file("https://oanda.com", destfile="/tmp/gh")
trying URL 'https://oanda.com'
downloaded 95 KB

> download.file("http://oanda.com", destfile="/tmp/gh")
trying URL 'http://oanda.com'
Error in download.file("http://oanda.com", destfile = "/tmp/gh") : 
  cannot open URL 'http://oanda.com'

请注意http / https上方的区别。

这对于任何其他域都是可重现的。我完全失去了,因为我不能谷歌任何其他人的痕迹。命令行中的wget适用于两个地址。

可能不相关的环境细节:我安装了RCurl。它是从AWS上安装的本地shiny服务器下运行的。 Ubuntu 14LTS。

所以,如何让quantmod使用https进行通话,或者如何让download.filehttp合作?

1 个答案:

答案 0 :(得分:4)

我在上面发表评论作为答案。

请参阅此错误报告:http://github.com/joshuaulrich/quantmod/issues/83

似乎curl存在问题。

如果wget工作正常,您可以遵循相同的建议并尝试使用R命令options(download.file.method="wget")来使用wget而不是curl进行quantmod下载。

相关问题