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.56k stars 1.14k forks source link

Getting detected by cloudflare #1388

Open vndhote opened 1 year ago

vndhote commented 1 year ago

undetected chromedriver worked well till yesterday but now, cloudflare improved and the chromedriver is not bypassing cloudflare. I have attached the screenshot of it. cloudflare is just looping the captcha when selenium is running. When I close it, the website loads. image This is my code snippet image It works fine when the script isn't running. I also tried changing the binary to chrome rather than brave, but the issue still persists

miha1llumi commented 1 year ago

I found out that if you open a new tab with js it passes cloudflare captchas. You can close the old tab and use the new one.

driver.execute_script('''window.open("http://nowsecure.nl","_blank");''') # open page in new tab
time.sleep(5) # wait until page has loaded
driver.switch_to.window(window_name=driver.window_handles[0])   # switch to first tab
driver.close() # close first tab
driver.switch_to.window(window_name=driver.window_handles[0] )  # switch back to new tab
time.sleep(2)
driver.get("https://google.com")
time.sleep(2)
driver.get("https://nowsecure.nl") # this should pass cloudflare captchas now

thanks, bro. Everything works.

iprahka commented 11 months ago

I found out that if you open a new tab with js it passes cloudflare captchas. You can close the old tab and use the new one.

driver.execute_script('''window.open("http://nowsecure.nl","_blank");''') # open page in new tab
time.sleep(5) # wait until page has loaded
driver.switch_to.window(window_name=driver.window_handles[0])   # switch to first tab
driver.close() # close first tab
driver.switch_to.window(window_name=driver.window_handles[0] )  # switch back to new tab
time.sleep(2)
driver.get("https://google.com")
time.sleep(2)
driver.get("https://nowsecure.nl") # this should pass cloudflare captchas now

Youre absolutely right, but at the the same time I just tried to comment out the '--headless' line and it works perfect too without any long loading

Here's my working code version:

from selenium import webdriver
import time
from config import proxy_ip, proxy_port # you can remove it and the option below

options = webdriver.ChromeOptions()
# options.add_argument("--headless")
options.add_argument(f"--proxy-server={proxy_ip}:{proxy_port}")
options.add_argument('--user-data-dir=/home/iprahka/.config/google-chrome/Default')

driver = undetected_chromedriver.Chrome(options)

driver.get('https://www.nowsecure.nl')

time.sleep(99)
Ahmed-Ashraf-Khalil commented 9 months ago

Screenshot 2023-11-23 034202

i saw this tool online garantee cloudflare verfication to be solved

cons: the documentation is in chinese and couldn't link it with selenium.

n0nameNPC commented 4 months ago

Apperently that's an issue with the cloudflare captchas. I found that it works when dev tools are open. Adding the following line resolved the issue for me. chrome_options.add_argument("--auto-open-devtools-for-tabs") # automatically open dev tools on every new tab (This is a not a pretty solution ofc, I had no time to dive deeper yet)

I tried your solutions, this and the new one and it works on my local machine. However it cannot seem to work on AWS ec2 or Digitalocean droplet. Do you have any pointers where to look to solve this?

are you using package for rendering ? For example: Xvfb

Ghxst commented 3 months ago

Apperently that's an issue with the cloudflare captchas. I found that it works when dev tools are open. Adding the following line resolved the issue for me. chrome_options.add_argument("--auto-open-devtools-for-tabs") # automatically open dev tools on every new tab (This is a not a pretty solution ofc, I had no time to dive deeper yet)

I tried your solutions, this and the new one and it works on my local machine. However it cannot seem to work on AWS ec2 or Digitalocean droplet. Do you have any pointers where to look to solve this?

are you using package for rendering ? For example: Xvfb

I am, I can relate to having issues automating my browsers whenever the system is headless and I rely on Xfvb. Any ideas why or tips to avoid detection of headless systems?