尽管GET请求有效,但未能在公司代理后面运行RSelenium? [英] Failing to run RSelenium behind Company Proxy, though GET requests work?

查看:48
本文介绍了尽管GET请求有效,但未能在公司代理后面运行RSelenium?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在公司代理后面运行RSelenium,并且可以通过GET请求成功连接,但是我无法正确运行rsDriver()函数.

I am attempting to run RSelenium behind my company's proxy and can connect successfully via GET requests, but I am unable to properly run the rsDriver() function.

set_config(use_proxy(url = "proxy.company.com",
                     port = 80,
                     username = "greg",
                     password = "password"))

完成此操作后,我就能够成功运行GET请求,如果不使用setconfig,我将无法执行该请求:

Upon doing this, I am successfully able to run a GET request, which I am unable to perform without using setconfig:

> GET("http://google.com")
Response [http://www.google.com/]
  Date: 2021-02-09 18:30
  Status: 200

我尝试使用rsDriver并获得与Chrome或Firefox的连接问题:

I try using rsDriver and get a connection issue with either Chrome or Firefox:

cprof <- list(chromeOptions = 
                list(args = list("--proxy-server=proxy.company.com")))

driver <- rsDriver(browser = c("chrome"), extraCapabilities = cprof)

检查Selenium Server版本:开始:预下载open.connection(con,"rb")中的错误:达到超时时间:[www.googleapis.com] 10014毫秒后操作超时,收到0字节中的0字节

checking Selenium Server versions: BEGIN: PREDOWNLOAD Error in open.connection(con, "rb") : Timeout was reached: [www.googleapis.com] Operation timed out after 10014 milliseconds with 0 out of 0 bytes received

我还是尝试与Docker客户端一起运行,并且在尝试连接后收到一条奇怪的消息:

I alternatively try to run with a Docker client, and I get a strange message after trying to connect:

> remDr <- remoteDriver(remoteServerAddr = "127.0.0.1", port = 444L) 
> remDr$open()
[1] "Connecting to remote server"
$id
[1] NA

我不知道为什么无论尝试如何都无法使它正常工作.任何指导都将挽救生命.

I am puzzled as to why I cannot get this to work, no matter what I try. Any guidance would be life saving.

谢谢

推荐答案

这是一个很难解决的问题,因为产生的错误实际上只是 NA .但是我发现有关如何在RSelenium中使用代理.基本上:

This is a hard problem to search for, since the resulting error is literally just NA. But I found this on how to use a proxy with RSelenium. Basically:

cprof <- list(chromeOptions = 
                  list(args = list("--proxy-server=http://118.69.61.212:53281")))

driver<- rsDriver(browser=c("chrome"), extraCapabilities = cprof)
driver$client$navigate("http://ipinfo.io")

但是您有一个硬编码的用户名和密码,由于无法与chrome一起使用,安全原因.

But you have a hard coded username and password, which is seems is not possible to use with chrome, due to security reasons.

但是,有人制作了一个脚本,该脚本可以使其正常工作(我没有尝试使用它,更不用说了R,非常有兴趣了解是否有人可以使用它.

However, someone made a script that can make it work (I haven't attempted to use it, let alone with R, very interested to hear if someone can make it work).

关于它的价值,我遇到了所有相同的问题,因此我通过代理后面的httr/rvest发出请求,但是对于通过RSelenium发出的请求,我使用了 httr :: reset_config()来停止使用代理,这样至少RSelenium可以工作(这不是解决此问题的方法,只是一种妥协).

For what it's worth, I faced all the same problems, so I made requests via httr/rvest behind a proxy, but for requests via RSelenium, I used httr::reset_config() to stop using proxies so at least RSelenium worked (that's not a solution to this problem, just a comprimise).

这篇关于尽管GET请求有效,但未能在公司代理后面运行RSelenium?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆