无法连接到主机,但URL在实际的Web浏览器中工作正常

时间:2023-01-07 22:45:42

I'm behind a VPN. And I think whoever administers it must have done some weird change lately because suddenly my script doesn't work.

我落后于VPN。我认为管理它的人最近必须做一些奇怪的改变,因为突然我的脚本不起作用。

It's not terribly important to know what the below is doing, basically logging into SFDC so that I can later download a CSV..

知道下面的内容并不是非常重要,基本上登录SFDC以便以后我可以下载CSV。

The point is that if I were to simply plop in the url string (https://login.salesforce.com/?un=username@domain.com&pw=password) into my web browser, it will work no problem. So why, with the EXACT same URL, is R unable to connect to host?

关键是,如果我只是将url字符串(https://login.salesforce.com/?un=username@domain.com&pw=password)放入我的网络浏览器,它将没有问题。那么,为什么使用EXACT相同的URL,R无法连接到主机?

library(RCurl)

agent="Firefox/23.0" 

options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))
curl = getCurlHandle()

curlSetOpt(
  cookiejar = 'cookies.txt' ,
  useragent = agent,
  followlocation = TRUE ,
  autoreferer = TRUE ,
  curl = curl
)
un="username@domain.com"
pw="password"

html = postForm(paste("https://login.salesforce.com/?un=", un, "&pw=", pw, sep=""), curl=curl)

1 个解决方案

#1


Alright I'm answering this myself because I finally figured it out!

好吧,我自己也在回答这个问题,因为我终于明白了!

I found that Internet Explorer had a Configuration Script. I mistakingly was using this script location as the proxy. I dived into the script and actually noticed that there was a variable that looked like a proper proxy. Once I popped that into my curlSetOpt, everything worked as it should!

我发现Internet Explorer有一个配置脚本。我错误地将此脚本位置用作代理。我潜入脚本并且实际注意到有一个变量看起来像一个合适的代理。一旦我将它弹出到我的curlSetOpt中,一切都按原样运行!

In case anyone is wondering, add this:

万一有人想知道,添加这个:

curlSetOpt(
  cookiejar = 'cookies.txt' ,
  useragent = agent,
  followlocation = TRUE ,
  autoreferer = TRUE ,
  curl = curl,
 .opts = list(proxy="proxylocation.com:8080")

)

#1


Alright I'm answering this myself because I finally figured it out!

好吧,我自己也在回答这个问题,因为我终于明白了!

I found that Internet Explorer had a Configuration Script. I mistakingly was using this script location as the proxy. I dived into the script and actually noticed that there was a variable that looked like a proper proxy. Once I popped that into my curlSetOpt, everything worked as it should!

我发现Internet Explorer有一个配置脚本。我错误地将此脚本位置用作代理。我潜入脚本并且实际注意到有一个变量看起来像一个合适的代理。一旦我将它弹出到我的curlSetOpt中,一切都按原样运行!

In case anyone is wondering, add this:

万一有人想知道,添加这个:

curlSetOpt(
  cookiejar = 'cookies.txt' ,
  useragent = agent,
  followlocation = TRUE ,
  autoreferer = TRUE ,
  curl = curl,
 .opts = list(proxy="proxylocation.com:8080")

)