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.9k stars 1.16k forks source link

new cloudflare captcha click #1543

Closed devCanario closed 1 year ago

devCanario commented 1 year ago

the now use a map tag with a area tag inside, and it dosent work with javascript, only works with the real mouse as far as i tested, can seem to be able to click it

vasilews commented 1 year ago

the now use a map tag with a area tag inside, and it dosent work with javascript, only works with the real mouse as far as i tested, can seem to be able to click it

This works

area = driver.find_element(
    By.CSS_SELECTOR,
    "map area",
)
driver.execute_script("arguments[0].click()", area)
devCanario commented 1 year ago

the now use a map tag with a area tag inside, and it dosent work with javascript, only works with the real mouse as far as i tested, can seem to be able to click it

This works

area = driver.find_element(
    By.CSS_SELECTOR,
    "map area",
)
driver.execute_script("arguments[0].click()", area)

what i mean its with the code you have it does click it, but it knows is javascript click and it will keep you in a captcha loop, but if you do it with your mouse, it does pass.

asm00009 commented 1 year ago

yeah it stays there even after click

NotABot438 commented 1 year ago
element = driver.find_element(By.CSS_SELECTOR, 'map img')
action = ActionChains(driver)
action.move_to_element(element).move_by_offset(0, 0).click().perform()

Move to the image, then move by no offset so you can click at the location instead of attempting to click the image and it will work

thebetauser commented 1 year ago

This works to get through regular click protection however there is another level of protection on CF that causes automated actions on the verification button to cause an infinite loop.

NotABot438 commented 1 year ago

This works to get through regular click protection however there is another level of protection on CF that causes automated actions on the verification button to cause an infinite loop.

try adding the following (from other issues in the last couple of months, not sure exactly where from anymore): option.add_argument('--auto-open-devtools-for-tabs') and if that doesn't work try adding this as your navigate for bypassing cloudflare:

driver.execute_script('window.open(\'url_here\', \'_blank\')')
# this sleep is required due to cloudflare noticing if you switch too quickly
sleep(random.randint(10, 15))
driver.switch_to.window(driver.window_handles[1])

edit: the button click issue is unrelated to the looping, the only thing you can't use is javascript executor since it's noticed

cardermeister commented 1 year ago
img = driver.find_element(By.XPATH, '//img')
checkrobot2 = driver.find_element(By.XPATH, '//area')
driver.execute_script("arguments[0].setAttribute('shape','circle');", checkrobot2)
x = img.location['x']
y = img.location['y']
print(get_now_str(),'[Log]','bypass area click:',x,y)
driver.execute_script("arguments[0].setAttribute('coords','"+str(x)+","+str(y)+",3');", checkrobot2)
checkrobot2.click()
BOT-Jester commented 1 year ago

I'm sorry, I'm rather new here, but I'm getting varying errors. I either get unable to locate element: {"method":"xpath","selector":"//img"} or unable to locate //area and sometimes it crashes upon not being able to find img.location['x']. Here is my code:

import time
import undetected_chromedriver as uc
from selenium.webdriver.common.by import By

driver = uc.Chrome()
# SEIZURE WARNING, FLASHING LIGHTS
driver.get('https://nowsecure.nl/') # SEIZURE WARNING, FLASHING LIGHTS
time.sleep(11.6)

#cardermeisters code
img = driver.find_element(By.XPATH, '//img')
print(img)
checkrobot2 = driver.find_element(By.XPATH, '//area')
driver.execute_script("arguments[0].setAttribute('shape','circle');", checkrobot2)
x = img.location['x']
y = img.location['y']
print('[Log]','bypass area click:',x,y)
driver.execute_script("arguments[0].setAttribute('coords','"+str(x)+","+str(y)+",3');", checkrobot2)
checkrobot2.click()
print(driver.text)

driver.close()

Here is a full log:

<undetected_chromedriver.webelement.WebElement (session="4b958a841466d4cfff76d64fb3c1b9db", element="F974F5A19E4174826D1F2F5561B506D0_element_7")>
Traceback (most recent call last):
  File "c:\Users\USER\Downloads\testing2.py", line 13, in <module>
    checkrobot2 = driver.find_element(By.XPATH, '//area')
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 739, in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 345, in execute
    self.error_handler.check_response(response)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response       
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//area"}
  (Session info: chrome=116.0.5845.180); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
        GetHandleVerifier [0x008D37C3+48947]
        (No symbol) [0x00868551]
        (No symbol) [0x0076C92D]
        (No symbol) [0x00799E38]
        (No symbol) [0x00799EFB]
        (No symbol) [0x007C8EF2]
        (No symbol) [0x007B50D4]
        (No symbol) [0x007C75DA]
        (No symbol) [0x007B4E86]
        (No symbol) [0x007916C7]
        (No symbol) [0x0079284D]
        GetHandleVerifier [0x00B1FDF9+2458985]
        GetHandleVerifier [0x00B6744F+2751423]
        GetHandleVerifier [0x00B61361+2726609]
        GetHandleVerifier [0x00950680+560624]
        (No symbol) [0x0087238C]
        (No symbol) [0x0086E268]
        (No symbol) [0x0086E392]
        (No symbol) [0x008610B7]
        BaseThreadInitThunk [0x76C100C9+25]
        RtlGetAppContainerNamedObjectPath [0x76F97B1E+286]
        RtlGetAppContainerNamedObjectPath [0x76F97AEE+238]

Exception ignored in: <function Chrome.__del__ at 0x000002354CE98900>
Traceback (most recent call last):
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\__init__.py", line 843, in __del__
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\__init__.py", line 798, in quit
OSError: [WinError 6] The handle is invalid

I apologize if it's something stupid, but I've been banging my head against a screen for a few hours now trying to figure this out. Any ideas? Does the code work for you?

tehneydobertz commented 1 year ago

I'm sorry, I'm rather new here, but I'm getting varying errors. I either get unable to locate element: {"method":"xpath","selector":"//img"} or unable to locate //area and sometimes it crashes upon not being able to find img.location['x']. Here is my code:

import time
import undetected_chromedriver as uc
from selenium.webdriver.common.by import By

driver = uc.Chrome()
# SEIZURE WARNING, FLASHING LIGHTS
driver.get('https://nowsecure.nl/') # SEIZURE WARNING, FLASHING LIGHTS
time.sleep(11.6)

#cardermeisters code
img = driver.find_element(By.XPATH, '//img')
print(img)
checkrobot2 = driver.find_element(By.XPATH, '//area')
driver.execute_script("arguments[0].setAttribute('shape','circle');", checkrobot2)
x = img.location['x']
y = img.location['y']
print('[Log]','bypass area click:',x,y)
driver.execute_script("arguments[0].setAttribute('coords','"+str(x)+","+str(y)+",3');", checkrobot2)
checkrobot2.click()
print(driver.text)

driver.close()

Here is a full log:

<undetected_chromedriver.webelement.WebElement (session="4b958a841466d4cfff76d64fb3c1b9db", element="F974F5A19E4174826D1F2F5561B506D0_element_7")>
Traceback (most recent call last):
  File "c:\Users\USER\Downloads\testing2.py", line 13, in <module>
    checkrobot2 = driver.find_element(By.XPATH, '//area')
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 739, in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 345, in execute
    self.error_handler.check_response(response)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response       
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//area"}
  (Session info: chrome=116.0.5845.180); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
        GetHandleVerifier [0x008D37C3+48947]
        (No symbol) [0x00868551]
        (No symbol) [0x0076C92D]
        (No symbol) [0x00799E38]
        (No symbol) [0x00799EFB]
        (No symbol) [0x007C8EF2]
        (No symbol) [0x007B50D4]
        (No symbol) [0x007C75DA]
        (No symbol) [0x007B4E86]
        (No symbol) [0x007916C7]
        (No symbol) [0x0079284D]
        GetHandleVerifier [0x00B1FDF9+2458985]
        GetHandleVerifier [0x00B6744F+2751423]
        GetHandleVerifier [0x00B61361+2726609]
        GetHandleVerifier [0x00950680+560624]
        (No symbol) [0x0087238C]
        (No symbol) [0x0086E268]
        (No symbol) [0x0086E392]
        (No symbol) [0x008610B7]
        BaseThreadInitThunk [0x76C100C9+25]
        RtlGetAppContainerNamedObjectPath [0x76F97B1E+286]
        RtlGetAppContainerNamedObjectPath [0x76F97AEE+238]

Exception ignored in: <function Chrome.__del__ at 0x000002354CE98900>
Traceback (most recent call last):
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\__init__.py", line 843, in __del__
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\__init__.py", line 798, in quit
OSError: [WinError 6] The handle is invalid

I apologize if it's something stupid, but I've been banging my head against a screen for a few hours now trying to figure this out. Any ideas? Does the code work for you?

you have to switch iframe before click

BOT-Jester commented 1 year ago

Alright, I've got it successfully clicking on the box (thank you :heart:), but it's just not passing the check for me, just entering the infinite loop instead (even if I force the click code to run multiple times). Does this work for anyone else? Thanks in advance, I appreciate you taking the time to help out someone newer.

import time
import undetected_chromedriver as uc
from selenium.webdriver.common.by import By

driver = uc.Chrome()
# SEIZURE WARNING
driver.get('https://nowsecure.nl/')  # SEIZURE WARNING 
time.sleep(9.6)

driver.switch_to.frame(driver.find_element(By.XPATH, "//iframe"))
img = driver.find_element(By.XPATH, '//img')
print(img)
checkrobot2 = driver.find_element(By.XPATH, '//area')
driver.execute_script("arguments[0].setAttribute('shape','circle');", checkrobot2)
x = img.location['x']
y = img.location['y']
print('[Log]','bypass area click:',x,y)
driver.execute_script("arguments[0].setAttribute('coords','"+str(x)+","+str(y)+",3');", checkrobot2)
checkrobot2.click()
time.sleep(20)
driver.switch_to.default_content()
print(driver.page_source)
driver.quit()
cardermeister commented 1 year ago

First, load Google, and then do the same as in this answer + open devtools

This works to get through regular click protection however there is another level of protection on CF that causes automated actions on the verification button to cause an infinite loop.

try adding the following (from other issues in the last couple of months, not sure exactly where from anymore): option.add_argument('--auto-open-devtools-for-tabs') and if that doesn't work try adding this as your navigate for bypassing cloudflare:

driver.execute_script('window.open(\'url_here\', \'_blank\')')
# this sleep is required due to cloudflare noticing if you switch too quickly
sleep(random.randint(10, 15))
driver.switch_to.window(driver.window_handles[1])

edit: the button click issue is unrelated to the looping, the only thing you can't use is javascript executor since it's noticed

BOT-Jester commented 1 year ago

That did it! Here is my full code with my barely semi-helpful comments in case anyone else comes along with the same level of knowledge as me! Thank you so much!

import time # for sleeps
import random # so sleeps are varied
import undetected_chromedriver as uc # the driver
from selenium.webdriver.common.by import By # to find various items on the page
from selenium.webdriver.chrome.options import Options # to have devtools open

options = Options()
options.add_argument('--auto-open-devtools-for-tabs')
driver = uc.Chrome(options=options)

driver.execute_script('window.open(\'https://www.google.com\', \'_blank\')') # first open  with chrome
time.sleep(random.randint(3, 6)) # wait for chrome to load
driver.execute_script('window.open(\'https://www.nowsecure.nl/#relax\', \'_blank\')') # second open with site of choice
time.sleep(random.randint(10, 15)) # this sleep is required due to cloudflare noticing if you switch too quickly
driver.switch_to.window(driver.window_handles[1]) # idk what this does, we are already in the Cloudflare frame

driver.switch_to.frame(driver.find_element(By.XPATH, "//iframe")) # get to iframe
img = driver.find_element(By.XPATH, '//img') # get the img so we can click the right thing
print(img)

checkrobot2 = driver.find_element(By.XPATH, '//area') # get the area so we can get rid of it (I think? idk) so we can click the right thing
driver.execute_script("arguments[0].setAttribute('shape','circle');", checkrobot2)

x = img.location['x']
y = img.location['y']
print('[Log]','bypass area click:',x,y)

driver.execute_script("arguments[0].setAttribute('coords','"+str(x)+","+str(y)+",3');", checkrobot2) # prepare to click
checkrobot2.click() # click!

time.sleep(10) # let cloudflare process/page load
print(driver.page_source) # print full page html
driver.quit() # quit

Have a wonderful day!

devCanario commented 1 year ago

That did it! Here is my full code with my barely semi-helpful comments in case anyone else comes along with the same level of knowledge as me! Thank you so much!

import time # for sleeps
import random # so sleeps are varied
import undetected_chromedriver as uc # the driver
from selenium.webdriver.common.by import By # to find various items on the page
from selenium.webdriver.chrome.options import Options # to have devtools open

options = Options()
options.add_argument('--auto-open-devtools-for-tabs')
driver = uc.Chrome(options=options)

driver.execute_script('window.open(\'https://www.google.com\', \'_blank\')') # first open  with chrome
time.sleep(random.randint(3, 6)) # wait for chrome to load
driver.execute_script('window.open(\'https://www.nowsecure.nl/#relax\', \'_blank\')') # second open with site of choice
time.sleep(random.randint(10, 15)) # this sleep is required due to cloudflare noticing if you switch too quickly
driver.switch_to.window(driver.window_handles[1]) # idk what this does, we are already in the Cloudflare frame

driver.switch_to.frame(driver.find_element(By.XPATH, "//iframe")) # get to iframe
img = driver.find_element(By.XPATH, '//img') # get the img so we can click the right thing
print(img)

checkrobot2 = driver.find_element(By.XPATH, '//area') # get the area so we can get rid of it (I think? idk) so we can click the right thing
driver.execute_script("arguments[0].setAttribute('shape','circle');", checkrobot2)

x = img.location['x']
y = img.location['y']
print('[Log]','bypass area click:',x,y)

driver.execute_script("arguments[0].setAttribute('coords','"+str(x)+","+str(y)+",3');", checkrobot2) # prepare to click
checkrobot2.click() # click!

time.sleep(10) # let cloudflare process/page load
print(driver.page_source) # print full page html
driver.quit() # quit

Have a wonderful day!

for me i didnt need to go to google and then go to the website try doing everything and before the checkrobot2.click() se a delay around 1 second and it passes for me

FranciscoPalomares commented 1 year ago

Hi It works, but if you use the same method with different browsers at the same time, the click stays in a loop and does not redirect to the page. Thanks

mehmetzerey commented 1 year ago

It works,

import time
import random
import undetected_chromedriver as uc
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options

def click_captcha(driver):
    try:
        iframe = driver.find_element(By.XPATH, "//iframe")
        driver.switch_to.frame(iframe)

        img = driver.find_element(By.XPATH, '//img')
        checkrobot2 = driver.find_element(By.XPATH, '//area')

        x = img.location['x']
        y = img.location['y']

        driver.execute_script("arguments[0].setAttribute('shape','circle');", checkrobot2)
        driver.execute_script("arguments[0].setAttribute('coords','"+str(x)+","+str(y)+",3');", checkrobot2)
        checkrobot2.click()
        driver.switch_to.default_content()

    except Exception as e:
        print("Error clicking captcha:", str(e))

def main():
    options = Options()
    options.add_argument('--disable-dev-shm-usage')
    options.add_argument('--no-sandbox')

    driver = uc.Chrome(headless=True,use_subprocess=False, options=options)

    try:
        driver.execute_script('window.open(\'https://www.google.com\', \'_blank\')')
        time.sleep(random.randint(3, 6))
        driver.execute_script('window.open(\'https://www.nowsecure.nl/#relax\', \'_blank\')')
        time.sleep(random.randint(10, 15))
        driver.switch_to.window(driver.window_handles[1])

        click_captcha(driver)

        time.sleep(10)
        print(driver.page_source)

        # Ekran görüntüsünü al ve kaydet
        driver.save_screenshot('site_screenshot.png')
    except Exception as e:
        print("An error occurred:", str(e))
    finally:
        driver.quit()

if __name__ == "__main__":
    main()
devCanario commented 1 year ago

new cloudflare click again, anyone got the js to bypass?

cardermeister commented 1 year ago

Right now, it works just as it did before the situation with the area. Try click on the checkbox.

try:
                        checkrobot = WebDriverWait(driver, 4).until(lambda d: d.find_element(By.XPATH, "//input[@type='checkbox']"))
                        checkrobot.click()
                    except:
                        img = driver.find_element(By.XPATH, '//img')
                        checkrobot2 = driver.find_element(By.XPATH, '//area')
                        driver.execute_script("arguments[0].setAttribute('shape','circle');", checkrobot2)
                        x = img.location['x']
                        y = img.location['y']
                        print(get_now_str(),'[Log]','bypass area click:',x,y)
                        driver.execute_script("arguments[0].setAttribute('coords','"+str(x)+","+str(y)+",3');", checkrobot2)
                        checkrobot2.click()
devCanario commented 1 year ago

Right now, it works just as it did before the situation with the area. Try click on the checkbox.

try:
                        checkrobot = WebDriverWait(driver, 4).until(lambda d: d.find_element(By.XPATH, "//input[@type='checkbox']"))
                        checkrobot.click()
                    except:
                        img = driver.find_element(By.XPATH, '//img')
                        checkrobot2 = driver.find_element(By.XPATH, '//area')
                        driver.execute_script("arguments[0].setAttribute('shape','circle');", checkrobot2)
                        x = img.location['x']
                        y = img.location['y']
                        print(get_now_str(),'[Log]','bypass area click:',x,y)
                        driver.execute_script("arguments[0].setAttribute('coords','"+str(x)+","+str(y)+",3');", checkrobot2)
                        checkrobot2.click()

in my case at the moment the click cloudflare gives me is this one image

and i cant just .click() the element it wont work

devCanario commented 1 year ago

just tried, just do document.querySelector(".mark").click(); works just fine

mateuslacorte commented 1 year ago

@canarioPorCanarias do I need to do the open window thing with execute_script like said before on this thread?

devCanario commented 1 year ago

@canarioPorCanarias do I need to do the open window thing with execute_script like said before on this thread?

no, just wait for the captcha to load on the opened window and execute script

lyaxsh commented 2 months ago

That did it! Here is my full code with my barely semi-helpful comments in case anyone else comes along with the same level of knowledge as me! Thank you so much!

import time # for sleeps
import random # so sleeps are varied
import undetected_chromedriver as uc # the driver
from selenium.webdriver.common.by import By # to find various items on the page
from selenium.webdriver.chrome.options import Options # to have devtools open

options = Options()
options.add_argument('--auto-open-devtools-for-tabs')
driver = uc.Chrome(options=options)

driver.execute_script('window.open(\'https://www.google.com\', \'_blank\')') # first open  with chrome
time.sleep(random.randint(3, 6)) # wait for chrome to load
driver.execute_script('window.open(\'https://www.nowsecure.nl/#relax\', \'_blank\')') # second open with site of choice
time.sleep(random.randint(10, 15)) # this sleep is required due to cloudflare noticing if you switch too quickly
driver.switch_to.window(driver.window_handles[1]) # idk what this does, we are already in the Cloudflare frame

driver.switch_to.frame(driver.find_element(By.XPATH, "//iframe")) # get to iframe
img = driver.find_element(By.XPATH, '//img') # get the img so we can click the right thing
print(img)

checkrobot2 = driver.find_element(By.XPATH, '//area') # get the area so we can get rid of it (I think? idk) so we can click the right thing
driver.execute_script("arguments[0].setAttribute('shape','circle');", checkrobot2)

x = img.location['x']
y = img.location['y']
print('[Log]','bypass area click:',x,y)

driver.execute_script("arguments[0].setAttribute('coords','"+str(x)+","+str(y)+",3');", checkrobot2) # prepare to click
checkrobot2.click() # click!

time.sleep(10) # let cloudflare process/page load
print(driver.page_source) # print full page html
driver.quit() # quit

Have a wonderful day!

brother can you help me a bit, im try to bypass the cf turnstile in middle of some other page, i have the script but unable to integrate your bypass script with this please help me integrating. im newbie in selenium so please help me na

cardermeister commented 2 months ago

That did it! Here is my full code with my barely semi-helpful comments in case anyone else comes along with the same level of knowledge as me! Thank you so much!

import time # for sleeps
import random # so sleeps are varied
import undetected_chromedriver as uc # the driver
from selenium.webdriver.common.by import By # to find various items on the page
from selenium.webdriver.chrome.options import Options # to have devtools open

options = Options()
options.add_argument('--auto-open-devtools-for-tabs')
driver = uc.Chrome(options=options)

driver.execute_script('window.open(\'https://www.google.com\', \'_blank\')') # first open  with chrome
time.sleep(random.randint(3, 6)) # wait for chrome to load
driver.execute_script('window.open(\'https://www.nowsecure.nl/#relax\', \'_blank\')') # second open with site of choice
time.sleep(random.randint(10, 15)) # this sleep is required due to cloudflare noticing if you switch too quickly
driver.switch_to.window(driver.window_handles[1]) # idk what this does, we are already in the Cloudflare frame

driver.switch_to.frame(driver.find_element(By.XPATH, "//iframe")) # get to iframe
img = driver.find_element(By.XPATH, '//img') # get the img so we can click the right thing
print(img)

checkrobot2 = driver.find_element(By.XPATH, '//area') # get the area so we can get rid of it (I think? idk) so we can click the right thing
driver.execute_script("arguments[0].setAttribute('shape','circle');", checkrobot2)

x = img.location['x']
y = img.location['y']
print('[Log]','bypass area click:',x,y)

driver.execute_script("arguments[0].setAttribute('coords','"+str(x)+","+str(y)+",3');", checkrobot2) # prepare to click
checkrobot2.click() # click!

time.sleep(10) # let cloudflare process/page load
print(driver.page_source) # print full page html
driver.quit() # quit

Have a wonderful day!

brother can you help me a bit, im try to bypass the cf turnstile in middle of some other page, i have the script but unable to integrate your bypass script with this please help me integrating. im newbie in selenium so please help me na

I think this method hasn't worked for a long time, but you can try commenting out all the clicks, use the Inspector f12 to find the necessary iframe and element, and then try clicking through the Inspector's console using any js code. If this works, you can then perform the click on the checkbox using x, y coordinates. I think you might have a nested iframe

lyaxsh commented 2 months ago

it is working fine as hell, I tried running this and it bypassed my site, is there any way I can contact you in person like telegram or smtg

On Wed, Aug 28, 2024, 8:39 PM _A @.***> wrote:

That did it! Here is my full code with my barely semi-helpful comments in case anyone else comes along with the same level of knowledge as me! Thank you so much!

import time # for sleeps import random # so sleeps are varied import undetected_chromedriver as uc # the driver from selenium.webdriver.common.by import By # to find various items on the page from selenium.webdriver.chrome.options import Options # to have devtools open

options = Options() options.add_argument('--auto-open-devtools-for-tabs') driver = uc.Chrome(options=options)

driver.execute_script('window.open(\'https://www.google.com\', \'_blank\')') # first open with chrome time.sleep(random.randint(3, 6)) # wait for chrome to load driver.execute_script('window.open(\'https://www.nowsecure.nl/#relax\', \'_blank\')') # second open with site of choice time.sleep(random.randint(10, 15)) # this sleep is required due to cloudflare noticing if you switch too quickly driver.switch_to.window(driver.window_handles[1]) # idk what this does, we are already in the Cloudflare frame

driver.switch_to.frame(driver.find_element(By.XPATH, "//iframe")) # get to iframe img = driver.find_element(By.XPATH, '//img') # get the img so we can click the right thing print(img)

checkrobot2 = driver.find_element(By.XPATH, '//area') # get the area so we can get rid of it (I think? idk) so we can click the right thing driver.execute_script("arguments[0].setAttribute('shape','circle');", checkrobot2)

x = img.location['x'] y = img.location['y'] print('[Log]','bypass area click:',x,y)

driver.execute_script("arguments[0].setAttribute('coords','"+str(x)+","+str(y)+",3');", checkrobot2) # prepare to click checkrobot2.click() # click!

time.sleep(10) # let cloudflare process/page load print(driver.page_source) # print full page html driver.quit() # quit

Have a wonderful day!

brother can you help me a bit, im try to bypass the cf turnstile in middle of some other page, i have the script but unable to integrate your bypass script with this please help me integrating. im newbie in selenium so please help me na

I think this method hasn't worked for a long time, but you can try commenting out all the clicks, use the Inspector f12 to find the necessary iframe and element, and then try clicking through the Inspector's console using any js code. If this works, you can then perform the click on the checkbox using x, y coordinates. I think you might have a nested iframe

— Reply to this email directly, view it on GitHub https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/1543#issuecomment-2315631569, or unsubscribe https://github.com/notifications/unsubscribe-auth/AX6YSHGN4W5LSOIOQG5F6LTZTXRZPAVCNFSM6AAAAABNHPFFXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJVGYZTCNJWHE . You are receiving this because you commented.Message ID: @.*** com>