I am using PhantomJS with selenium and I am trying to change the user-agent, but it will not change. I studied the selenium code, and trying to change the headers, but nothing works. Does anybody have a solution?
|
Python
PhantomJS useragent |
(Jan 13, 2019 04:14 PM)FW1738 Wrote: I am using PhantomJS with selenium and I am trying to change the user-agent, but it will not change. I studied the selenium code, and trying to change the headers, but nothing works. Does anybody have a solution? I usually use firefox or chrome with the headless option instead of phantomjs (during the years python support has been dropped often) Anyway can you try this code: Code from selenium import webdriver(Jan 14, 2019 03:20 AM)FriendZone Wrote: I usually use firefox or chrome with the headless option instead of phantomjs (during the years python support has been dropped often) Since when do Chrome and Firefox have headless options? ![]() Donate: 3ABKRghau93ziRaDfVwiiwtjky3i1gLrKn (Jan 14, 2019 07:59 AM)lockhead Wrote: Since when do Chrome and Firefox have headless options? Since always ahah No, I’ m not sure when, but since years In few mins I will post firefox headless (Jan 14, 2019 08:13 AM)FriendZone Wrote: Since always ahah Damn.. it's been a while since I needed something like this but a few years ago I had to deal with this PhantomJS BS because apparently it was the only option... ![]() Donate: 3ABKRghau93ziRaDfVwiiwtjky3i1gLrKn
Jan 14, 2019 08:39 AM
(This post was last modified: Jan 14, 2019 08:41 AM by FriendZone.)
(Jan 14, 2019 08:16 AM)lockhead Wrote: Damn.. it's been a while since I needed something like this but a few years ago I had to deal with this PhantomJS BS because apparently it was the only option... Code from selenium.webdriver import FirefoxN.B. I wrote the code without a pc close to me to test it . Keep in mind firefox is slower than chrome in headless mode (I read time ago a speed test article about it) Switch BINARY PATH and GECKODRIVER PATH with the right paths tell me if you need help
Jan 14, 2019 09:24 AM
(This post was last modified: Jan 14, 2019 09:24 AM by FW1738.)
(Jan 14, 2019 03:20 AM)FriendZone Wrote: I usually use firefox or chrome with the headless option instead of phantomjs (during the years python support has been dropped often) Doesn't work for me. When I print the navigator.userAgent, I still get the same. I got phantomjs version 2.1.1, think that is the newest. That shouldn't be the problem. Does the code work for you? (Jan 14, 2019 09:24 AM)FW1738 Wrote: Doesn't work for me. When I print the navigator.userAgent, I still get the same. I got phantomjs version 2.1.1, think that is the newest. That shouldn't be the problem. Does the code work for you? As stated I don’t use phantomjs but firefox, so I didn’t test it, as soon I will be at home I will find a working way if possible :) (Jan 14, 2019 09:27 AM)FriendZone Wrote: As stated I don’t use phantomjs but firefox, so I didn’t test it, as soon I will be at home I will find a working way if possible :) Thank you, do you know if firefox gets detected easily by for example recaptcha? (Jan 14, 2019 09:30 AM)FW1738 Wrote: Thank you, do you know if firefox gets detected easily by for example recaptcha? I would play with profiles and proxies. Do you need an example to set it in firefox?
I must add that running chrome headless vs firefox is a much greater gain if your looking for as little resource usage as possible.
Headless firefox and the non-headless version aren't that different in resource consumption, where as chrome is 30% less than it's non-headless version. |
|
|


![[Image: 0DvFxnA.gif]](https://i.imgur.com/0DvFxnA.gif)