简体   繁体   English

如何使用 selenuim 在 web 驱动程序中处理 Cloudflare Turnstile

[英]how to procses Cloudflare Turnstile in web driver with selenuim

i try to use selenuim module to get for some website unsuccsesfull.我尝试使用 selenuim 模块来获取某些网站不成功。 this is what i try: undetected_chromedriver add user profile use proxy.这就是我的尝试:undetected_chromedriver 添加用户配置文件使用代理。 when i open it with webdriver the Cloudflare not allow me to process.当我用 webdriver 打开它时,Cloudflare 不允许我处理。 when i open it with normal chrom its works fine.当我用普通 chrom 打开它时,它工作正常。 any idias?有idias吗?

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from datetime import datetime
import time
from undetected_chromedriver import Chrome

now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print('Hey Elior, im on = ', current_time)

options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\Owner\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 12")

driver = Chrome(chrome_options=options)
driver.get("https://www.example.com")

def login():
    driver.get("site")
    # identify username, password and signin elements
    time.sleep(1)
    driver.find_element(By.NAME, "username").click()
    driver.find_element(By.NAME, "username").send_keys('')

    time.sleep(1)
    driver.find_element(By.NAME, "password").click()
    driver.find_element(By.NAME, "password").send_keys('')

    time.sleep(1)
    # press on login button
    driver.find_element(By.ID, "login-submit").click()

    driver.maximize_window()
    driver.execute_script("console.clear()")  # clean the console
    time.sleep(3)

You could try using Selenium-Profiles .您可以尝试使用Selenium-Profiles

Note that headless almost never works undetected.请注意,headless 几乎永远不会在未被发现的情况下工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM