如何在Selenium中为代理类型设置PhantomJSOptions? [英] How to set the PhantomJSOptions in Selenium for proxy-type?

查看:245
本文介绍了如何在Selenium中为代理类型设置PhantomJSOptions?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为Web抓取项目的一部分,使用Selenium和Web驱动程序来驱动phantomjs.在PhantomJS的Windows已知问题"中,建议将代理类型设置为无"以加快网络性能.

Using Selenium and the web driver to drive phantomjs as part of a web scraping project. From the "Known Issues" for Windows at PhantomJS, it is suggested that the proxy-type be set to "none" to speed up network performance.

我尝试了以下操作:

PhantomJSOptions options = new PhantomJSOptions();
options.AddAdditionalCapability("proxy", "{proxyType:none}");

但是,这将代理设置为字符串,我想我需要一个json对象.有人可以告诉我如何正确执行此操作吗?

However, this sets proxy to a string and I think I need a json object. Can someone show me how to do this correctly?

推荐答案

使用驱动程序服务来设置选项:

Use the driver service to set options:

var phantomJSDriverService = PhantomJSDriverService.CreateDefaultService(phantomJsDir);
phantomJSDriverService.ProxyType = "none";
var driver = new PhantomJSDriver(phantomJSDriverService);

这篇关于如何在Selenium中为代理类型设置PhantomJSOptions?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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