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
10.13k stars 1.17k forks source link

Still asking for captcha #1623

Open jesseimming opened 1 year ago

jesseimming commented 1 year ago

When opening, it still gives me the "checking if site is secure" problem. This is the code I used, did I do anything wrong? nowsecure

jesseimming commented 1 year ago

import undetected_chromedriver as uc import time

if name == 'main': options = uc.ChromeOptions() options.add_argument('--headless') driver = uc.Chrome(options=options, use_subprocess=True) driver.get('https://nowsecure.nl') time.sleep(5) driver.save_screenshot('nowsecure.png') # Wait for 5 seconds to ensure that the browser has fully loaded driver.quit()

MovingW commented 1 year ago

You could try to open a new tab manually, and paste the url. You'll find it works. I have no idea why it works like this.😂

txtsd commented 1 year ago

It's because of new tech called Turnstile.

eem1r commented 1 year ago

https://stackoverflow.com/questions/76582307/i-am-using-undetected-chromedriver

I'm a beginner in Python, but the page loads without any problems in Seleniumbase. I'm thinking of converting my projects to seleniumbase.

dexedrine-01 commented 1 year ago

It's because of new tech called Turnstile.

Date: 28/09/2022

It's not new.

txtsd commented 1 year ago

Curious. I read that on Hacker News several days ago and assumed it was NEWs.

pedro-peixot0 commented 1 year ago

The issue is with the window undetected chrome driver is focused on. Somehow cloudflare can detect that. The way arround is to load pages without focusing in them, you can do that this way:

 driver.execute_script(f"window.open('{URL}', '_blank');")
 time.sleep(3)
driver.switch_to.window(driver.window_handles[1])

Note that I am waiting for CloudFlare validation before switching to the window. This solves the issue for now

pedro-peixot0 commented 1 year ago

Actually the issue is not even focusing in the screen during Clouflare validation; If you ever focused on the screen the validation will fail even if you are not there while the validation is being done

  driver.execute_script(f"window.open('_blank', 'Testing');")
  driver.switch_to.window(driver.window_handles[1]
  driver.switch_to.window(driver.window_handles[0]
  driver.execute_script(f"window.open('{URL}', 'Testing');")

Even though I am not focusing on the testing window while the URL is loaded, it will be caught by cloudflare

MovingW commented 1 year ago

The issue is with the window undetected chrome driver is focused on. Somehow cloudflare can detect that. The way arround is to load pages without focusing in them, you can do that this way:

 driver.execute_script(f"window.open('{URL}', '_blank');")
 time.sleep(3)
driver.switch_to.window(driver.window_handles[1])

Note that I am waiting for CloudFlare validation before switching to the window. This solves the issue for now

I was wondering how did the website detected if the window is being focused on or not? I've tried opening a new tab manually and executing switching to new window before opening the page, and the other time after opening the page. They all failed.

wzqwwq commented 1 year ago

The issue is with the window undetected chrome driver is focused on. Somehow cloudflare can detect that. The way arround is to load pages without focusing in them, you can do that this way:

 driver.execute_script(f"window.open('{URL}', '_blank');")
 time.sleep(3)
driver.switch_to.window(driver.window_handles[1])

Note that I am waiting for CloudFlare validation before switching to the window. This solves the issue for now

It works for me. I cannot bypass detection even if manually enter the web url but this solution works.

ghost commented 1 year ago

Maybe I'm missing something here, I would assume:

driver.execute_script(f"window.open('{URL}', '_blank');")

Will open a new tab and focus it anyway?

ghost commented 1 year ago

I resorted to xvfb and it comes with the benefit of being able to record everything.