使用PhantomJS在RSelenium中设置代理 [英] Setting proxy in RSelenium with PhantomJS

查看:91
本文介绍了使用PhantomJS在RSelenium中设置代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在remoteDriver命令中将RSelenium库与参数browserName = "phantomjs"一起使用,但是我想运行一个测试,以指定代理服务器的类型.我已经看到代理身份验证是可行的,例如 Java ,此处使用的代码如下:

I'm using the RSelenium library with the argument browserName = "phantomjs" in the remoteDriver command, however I was looking to run a test where I specify the type of the proxy server. I've seen that proxy authentication is possible in, e.g. Java, with the code used shown here:

ArrayList<String> cliArgsCap = new ArrayList<String>();
cliArgsCap.add("--proxy=address:port");
cliArgsCap.add("--proxy-auth=username:password");
cliArgsCap.add("--proxy-type=http");
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
capabilities.setCapability(
PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);
WebDriver driver = new PhantomJSDriver(capabilities);

以上内容可以在R中复制吗?

Can the above be replicated in R?

推荐答案

以下方法应该起作用:

library(RSelenium)
pJS <- phantom(extras = c("--proxy=192.168.1.42:8080")
                           , "--proxy-auth=username:password"
                           , "--proxy-type=http")
)
remDr <- remoteDriver(browserName = "phantomjs")
remDr$open()

这篇关于使用PhantomJS在RSelenium中设置代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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