How to set the PhantomJSOptions in Selenium for proxy-type?

落花浮王杯 提交于 2019-12-25 18:41:49

问题


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.

I tried the following:

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

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


回答1:


Use the driver service to set options:

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


来源:https://stackoverflow.com/questions/16948698/how-to-set-the-phantomjsoptions-in-selenium-for-proxy-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!