문제

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