使用selenium进行抓取却遇到cloudflare的人工检查

问题描述 投票:0回答:1

在我总是使用 python selenium 抓取的网站中添加了 cloudflare 的人工检查。

我查找了一些方法来跳过这种人工检查,例如 unDetected_chromedriver 或 zenrows, 甚至使用cookie来尝试欺骗cloudflare,但仍然没有成功。

有人有好主意跳过它吗?

enter image description here

我的代码如下。

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.service import Service

service = Service(executable_path='./chromedriver')
driver = webdriver.Chrome(service=service)

# driver = webdriver.Chrome(executable_path='./chromedriver')
url = 'target'
driver.get(url)

username_input = driver.find_element(By.ID, "userLoginForm.userId")

username_input.send_keys("username")

password_input = driver.find_element(By.ID, "userLoginForm.userPasswd")
password_input.send_keys("password")

loginBtn = driver.find_element(By.XPATH, '//*[@id="js-main"]/div/div[2]/div/input')
loginBtn.click()

请帮助我跳过 cloudflare 的人工检查。 预先感谢您。

python selenium-webdriver selenium-chromedriver cloudflare scrape
1个回答
0
投票

休眠 60 秒并打开一个新选项卡,将驱动程序保持在第一个选项卡,手动解决验证码,然后关闭选项卡并返回到驱动程序当前所在的原始选项卡,然后转到您想要抓取和验证码的目的地应该走了,你可以继续你的一天

© www.soinside.com 2019 - 2024. All rights reserved.