Art*_*hur 1 url ssl curl r quantmod
I\xe2\x80\x99m 尝试使用quantmodR 中的包从雅虎获取财务数据。它在我的个人笔记本电脑(Mac 和 Win)上完美运行。但我无法让它在我的工作计算机(Win7)上运行。
我的代码是:
\ngetSymbols("JPM", src = "yahoo")\nRun Code Online (Sandbox Code Playgroud)\n请注意,它仅不适用于我公司的笔记本电脑。
\n这是错误代码:
\nError in curl::curl_download(cu, tmp, handle = h) : \nSSL certificate problem: unable to get local issuer certificate\nRun Code Online (Sandbox Code Playgroud)\n我尝试通过以下方式解决问题:
\n安装httr包
删除curl并quantmod重新安装
更新到最新版本的 R、RStudio curl、、、httr和RCurlquantmod
安装openssl包
放ssl_verifypeer = 0L
之前添加以下内容getSymbols
options(download.file.method = "wget", download.file.extra = c("--no-check-certificate"))
不幸的是,以上方法都不起作用。顺便说一句,从谷歌财务获取数据是可行的,但谷歌每个请求只提供约 4000 条记录。
\n我认为我们公司对 SSL 有一些限制,但我完全可以访问以 https:// 开头的网站
\n另外,以下代码也有效:
\nlibrary('httr') \ncontent(GET('https://www.linkedin.com/in/lillyzhu'))\nRun Code Online (Sandbox Code Playgroud)\n和
\ndevtools::install_github\nRun Code Online (Sandbox Code Playgroud)\n我花了一周的时间来解决这个问题,但没有取得任何进展。现在我想知道是否可以修复它?任何想法都会有帮助!
\n感谢所有贡献者,祝您一切顺利!\n附录:输出libcurlVersion()
[1] "7.40.0"\nattr(,"ssl_version")\n[1] "OpenSSL/1.0.0o"\nattr(,"libssh_version")\n[1] "libssh2/1.4.3"\nattr(,"protocols")\n [1] "dict" "file" "ftp" \n [4] "ftps" "gopher" "http" \n [7] "https" "imap" "imaps" \n[10] "ldap" "pop3" "pop3s" \n[13] "rtmp" "rtsp" "scp" \n[16] "sftp" "smtp" "smtps" \n[19] "telnet" "tftp" \nRun Code Online (Sandbox Code Playgroud)\n如果您需要我的笔记本电脑的任何其他信息,请随时告诉我。
\n更新:我在公司笔记本电脑上测试了该功能,没有登录 VPN,它可以工作。那么有什么办法让它在 VPN 内工作吗?
\n该错误通常是由过期或丢失的 CA 根证书包引起的,但当远程服务器使用自签名证书时也可能会发生该错误。无论哪种情况,cURL 都无法验证远程服务器的证书并引发错误。
您可以使用以下方法禁用验证证书的要求:
library(httr)
httr::set_config(config(ssl_verifypeer = FALSE))
Run Code Online (Sandbox Code Playgroud)
但是,不建议这样做,因为它会产生安全漏洞。