Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nodriver] headless=True gets detected #1848

Open
J1398877 opened this issue Apr 28, 2024 · 7 comments
Open

[nodriver] headless=True gets detected #1848

J1398877 opened this issue Apr 28, 2024 · 7 comments

Comments

@J1398877
Copy link

First of all thank you for the great package.
It works fine, if headless = False but when switch to headless=True, it gets detected.
Any guidance to address this?
Tested @ s a h i b i n d e n dot c o m

@unlucky-kit
Copy link

First of all thank you for the great package.

It works fine, if headless = False but when switch to headless=True, it gets detected.

Any guidance to address this?

Tested @ s a h i b i n d e n dot c o m

Some websites have stronger detection algorithms so when running headless you are more likely to get detected.

As a workaround, you can use a virtual display and run non-headless to get similar functionality but at a cost of more computational power.

@Wajih-Wanis
Copy link

I got the same issue since the last month, as headless mode gets detected so I worked around it using a virtual display.

from pyvirtualdisplay import Display
display = Display(visible=0, size=(800,600))
display.start()

Having said that, if you are using a linux vps you will need xvfb package.
Hope this helps.

@CantCode023
Copy link

@Wajih-Wanis can you elaborate more on this method? I'd like to implement it in my code but I don't quite get how I can continue after display.start(), is it supposed to replace nodriver.start()?

@axiangcoding
Copy link

Same issue for me.

@Wajih-Wanis How the virtual display worked in code? Could you please provide a example?

@Daldude1
Copy link

use --headless=chrome

@Wajih-Wanis
Copy link

@Wajih-Wanis can you elaborate more on this method? I'd like to implement it in my code but I don't quite get how I can continue after display.start(), is it supposed to replace nodriver.start()?

from pyvirtualdisplay import Display
display = Display(visible=0, size=(1080,720))
display.start()
#Have your code here
display.stop()

@Wajih-Wanis
Copy link

@Wajih-Wanis can you elaborate more on this method? I'd like to implement it in my code but I don't quite get how I can continue after display.start(), is it supposed to replace nodriver.start()?

This code snippet should wrap your whole automation process. Write your code as if it going to run in normal mode ( not headless ) and add those at the start of the code. It will run in non headless but it will not have any visible display.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants