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

Do not bypass cloudflare with headless active after 117 update. #1577

Open
wnx3 opened this issue Sep 23, 2023 · 5 comments
Open

Do not bypass cloudflare with headless active after 117 update. #1577

wnx3 opened this issue Sep 23, 2023 · 5 comments

Comments

@wnx3
Copy link

wnx3 commented Sep 23, 2023

Do not bypass cloudflare with headless active after 117 update.
Does anyone have any alternatives to resolve this?

@wnx3
Copy link
Author

wnx3 commented Sep 23, 2023

use hidemium.io

I'm talking about Undetected Chromedriver

@tehneydobertz
Copy link

use hidemium.io

I'm talking about Undetected Chromedriver

ud chromedriver is currently outdated

@YabberWalkie
Copy link

YabberWalkie commented Sep 30, 2023

Yeah Chrome 117 Headless is currently being detected and haven't seen a fix yet :(

My workaround was downloading the portable version of Chrome 116, and then overriding the chrome executable path to chrome driver to 'GoogleChromePortable/App/Chrome-bin/chrome.exe'

Update:
Apparently its just the User Agent that contains HeadlessChrome, so overriding the ua to something else will fix the issue.

So adding the normale Chrome user agent to the webdriver will also work, just add the UA to the driver options before starting the driver.

    ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
    options.add_argument(f'--user-agent={ua}')

@andinua
Copy link

andinua commented Oct 5, 2023

Yeah Chrome 117 Headless is currently being detected and haven't seen a fix yet :(

My workaround was downloading the portable version of Chrome 116, and then overriding the chrome executable path to chrome driver to 'GoogleChromePortable/App/Chrome-bin/chrome.exe'

Update: Apparently its just the User Agent that contains HeadlessChrome, so overriding the ua to something else will fix the issue.

So adding the normale Chrome user agent to the webdriver will also work, just add the UA to the driver options before starting the driver.

    ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
    options.add_argument(f'--user-agent={ua}')

This helped, thank you!

@matez0
Copy link

matez0 commented Dec 15, 2023

@Helza , @andinua , could you modify the following docker file or provide a docker file for a container in which passing the cloudflare can be reproduced?

My try cannot reproduce the expected behavior:

# Dockerfile
FROM selenoid/chrome:116.0

USER root

RUN apt-get update || true

RUN apt-get install -y --no-install-recommends pip

RUN pip install undetected-chromedriver

RUN mkdir /test

WORKDIR /test

ENTRYPOINT ["python3", "test.py"]

with the modified test script from the documentation:

# test.py
from time import sleep

import undetected_chromedriver as uc

options = uc.ChromeOptions()

options.headless=True

ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
options.add_argument(f'--user-agent={ua}')

driver = uc.Chrome(version_main=116, headless=True, use_subprocess=False, options=options)
driver.get('https://nowsecure.nl')
sleep(5)
driver.save_screenshot('nowsecure.png')

and building the image and running the container:

docker build -t loc-ud-chrome-116 .
docker run --rm -v $PWD:/test loc-ud-chrome-116

Note: see #1600 for the remote version.

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

5 participants