我在Windows上的R中尝试了以下代码:
library(RCurl)
postForm("https://www.google.com/accounts/ClientLogin/",
"email" = "me@gmail.com",
"Passwd" = "abcd",
"service" = "finance",
"source" = "Test-1"
)
Run Code Online (Sandbox Code Playgroud)
但是出现以下错误:
Error in postForm()
SL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Run Code Online (Sandbox Code Playgroud)
如何设置RCurl以允许使用HTTP?
小智 13
只需将.opts = list(ssl.verifypeer = FALSE)添加到您的查询中
postForm("https://www.google.com/accounts/ClientLogin/",
"email" = "me@gmail.com",
"Passwd" = "abcd",
"service" = "finance",
"source" = "Test-1",
.opts = list(ssl.verifypeer = FALSE))
Run Code Online (Sandbox Code Playgroud)
Mis*_*urg 11
您需要安装SSL库.
对于Windows,你可以在这里找到一个:下载"OpenSSL for Windows"版本0.9.8k
解压缩到临时文件夹,并将文件"libeay32.dll"和"ssleay32.dll"从"bin"子文件夹复制到R\library\RCurl\lib\i386.
您也可以将其复制到与R.exe相同的目录中.
然后检查您是否可以访问https协议:
library(RCurl)
curlVersion()$protocol
## [1] "tftp" "ftp" "telnet" "dict" "ldap" "http" "file" "https"
## [9] "ftps" "scp" "sftp"
Run Code Online (Sandbox Code Playgroud)然后安装一组新的凭据文件:
ca-bundle.crt可以在以下网址找到:http://curl.haxx.se/ca/cacert.pem
重命名/复制到ca-bundle.crt
用这个测试:
getURL("https://www.google.com/accounts/ClientLogin/?service=finance&email=me@gmail.com&Passwd=abcd&source=Test-1",
cainfo = "path to R/library/RCurl/CurlSSL/ca-bundle.crt")
Run Code Online (Sandbox Code Playgroud)