質問

I've been playing around with Selenium and PhantomJS in C# but I want to be able to fake my User Agent to be this:

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0

Instead of:

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34

Is it possible to modify the HTTP headers of PhantomJS with Selenium to achieve this? If so, how?

Thanks in advance.

役に立ちましたか?

解決

I found the answer:

PhantomJSOptions options = new PhantomJSOptions();
options.AddAdditionalCapability("phantomjs.page.settings.userAgent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0");
IWebDriver driver = new PhantomJSDriver(options);

Thanks.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top