undetected-chromedriver icon indicating copy to clipboard operation
undetected-chromedriver copied to clipboard

[nodriver] headless=True gets detected

Open J1398877 opened this issue 9 months ago • 8 comments

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

J1398877 avatar Apr 28 '24 11:04 J1398877

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.

unlucky-kit avatar Apr 28 '24 22:04 unlucky-kit

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.

Wajih-Wanis avatar May 03 '24 09:05 Wajih-Wanis

@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()?

CantCode023 avatar May 04 '24 06:05 CantCode023

Same issue for me.

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

axiangcoding avatar May 06 '24 01:05 axiangcoding

use --headless=chrome

Daldude1 avatar May 17 '24 14:05 Daldude1

@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 avatar May 18 '24 11:05 Wajih-Wanis

@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.

Wajih-Wanis avatar May 18 '24 11:05 Wajih-Wanis

@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.

not working with some more arguments??? browser = await display.start(browser_args=[f"--proxy-server={PROXY}"], headless=False) error

marioeivissa avatar Jun 12 '24 21:06 marioeivissa