ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.95k stars 1.16k forks source link

Cannot pass cloudflare protection #246

Open IlliaFransua opened 3 years ago

IlliaFransua commented 3 years ago

My Google Chrome version: 92.0.4515.107 (Official Build), (64 bit)

My Python version: 3.9.3

When I try to run the code you provided, it doesn't go through the Cloudflare protection. Code:

import undetected_chromedriver.v2 as uc
driver = uc.Chrome ()
with driver:
    driver.get ('https://nowsecure.nl')
ultrafunkamsterdam commented 3 years ago

Then your ip is flagged/dirty. Do some regular surfing, solve some captchas, or get a new ip.

Copy pasting this code gives me the nice flashing page

PCPisChill commented 3 years ago

I don't think it's an ip thing, I'm getting the same error on some cloudflare sites (possibly some extra-protection mode is enabled on them), I'll go to the page on the same ip in a normal browser and it says "Checking your browser before accessing" and then it'll refresh into the regular page with a single Ray ID, but in Undetected-Chromedriver it just refreshes the "Checking your browser before accessing" infinitely with a different Ray ID each time.

I noticed if I keyboard interrupt my script to end it but not close the selenium browser, Cloudflare will refresh into the regular page right after that, but if I have a time.sleep(99999) (or WebDriverWait) while waiting for the page it will just infinite refresh the Cloudflare page.

import undetected_chromedriver.v2 as uc

driver = uc.Chrome(version_main=92, patcher_force_close=True)
with driver:
    driver.get('https://nowsecure.nl')

Works but

import undetected_chromedriver.v2 as uc
import time

driver = uc.Chrome(version_main=92, patcher_force_close=True)
with driver:
    driver.get('https://nowsecure.nl')
    time.sleep(9999)

Infinite refreshes (so you're unable to script anything).

ultrafunkamsterdam commented 3 years ago

Remove the sleep from the 'with' scope. And it will work. Timing is key here and you are interfering the workings of the driver this way. Using with already has sleep built in

ultrafunkamsterdam commented 3 years ago

Just move the sleep 4 positions to the left

PCPisChill commented 3 years ago

Remove the sleep from the 'with' scope. And it will work. Timing is key here and you are interfering the workings of the driver this way. Using with already has sleep built in

I see, my script did not use 'with driver:' and no longer gets stuck with it, thanks!

import undetected_chromedriver.v2 as uc

driver = uc.Chrome(version_main=92, patcher_force_close=True)
with driver: driver.get('https://nowsecure.nl')
driver.find_element_by_xpath("//a[@class='btn btn-lg btn-secondary fw-bold border-white bg-white']").click()
driver.quit()
minh7296 commented 2 years ago

In my case, it's super weird, for the same site and same Wifi , same IP , my laptop bypass cloadflare but my PC didn't. I can't find the problem here please help me

import undetected_chromedriver.v2 as uc
from time import sleep

if __name__ == '__main__':
    driver = uc.Chrome(version_main=96, patcher_force_close=True)
    driver.get('https://swee.ps/SsjNs_ecByaoG')  # known url using cloudflare's "under attack mode"
    sleep(8888)