绕过点击并按住python selenium

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

所以我想抓取一个网站,但是有一个问题,每当我尝试进入该网站时,都会有一个“单击并按住”验证码,我无法解决。 enter image description here

我已经在我的代码中添加了这些参数

option.add_argument('--profile-directory=Default')
option.add_argument("--incognito")
option.add_argument("--disable-plugins-discovery")
option.add_argument("--start-maximized")
option.add_argument('--ignore-certificate-errors')
option.add_argument('--allow-running-insecure-content')
option.add_argument("--disable-extensions")
option.add_argument("--proxy-server='direct://'")
option.add_argument("--proxy-bypass-list=*")
option.add_argument('--disable-dev-shm-usage')
option.add_argument('--no-sandbox')

我已经尝试使用selenium中的actionchain来解决验证码问题,但是没有迹象表明该按钮被单击。

element = browser.find_element_by_css_selector('#px-captcha')
action = ActionChains(browser)
action.click_and_hold(element).perform()
time.sleep(14)
action.release(element).perform()
time.sleep(0.2)
action.release(element)

有人知道如何使用selenium而不是pyautogui解决这个问题吗?

我尝试进入的网站: https://www.chegg.com/study

python selenium automation captcha
2个回答
0
投票

还可以使用 Chromedriver UnDetected.. 集成非常简单

pip install undetected-chromedriver

您可以按照下面的 git 链接进行设置。 https://github.com/ultrafunkamsterdam/unDetected-chromedriver

import undetected_chromedriver as uc
driver = uc.Chrome()
driver.get('https://www.example.com')

0
投票

还有其他方法可以绕过这个验证码吗?我们可以使用 pyautogui 和 playwright 的组合来绕过这个验证码吗?

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