我使用RStudio并且在公司防火墙后面,并将.Renviron文件设置为:
options(internet.info = 0)
http_proxy="http://user:pw@proxy:port"
http_proxy_user="user:pw"
https_proxy="https://user:pw@proxy:port"
https_proxy_user="user:pw"
库(HTTR)
如果我这样做:
raw.result <- GET(url = "http://www.example.com/")
它有效但如果我运行
raw.result <- GET(url = "https://www.example.com/")
我一直收到这个错误:
Error in curl::curl_fetch_memory(url, handle = handle) :
error setting certificate verify locations:
CAfile: /mingw64/ssl/certs/ca-bundle.crt
CApath: none
我一直在寻找解决方案,但无法弄清楚为什么会这样。
答案 0 :(得分:1)
您需要将https代理设置为系统环境变量而不是R变量。
#if you are using Windows you can use this to get the proxy server and port
companyproxy <- curl::ie_proxy_info()$Proxy
#set http proxy due to company's firewall
Sys.setenv(http_proxy=companyproxy)
Sys.setenv(https_proxy=companyproxy)
#GET a https website
raw.result <- GET(url="https://httpbin.org")