如何在Selenium中为代理类型设置PhantomJSOptions?

如何在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);