首页 > 解决方案 > 使用 selenium 和 anticaptchaofficial 解决验证码

问题描述

我一直在尝试使用 selenium 和 anticaptchaofficial来解决此页面上的验证码。一切正常.. 它返回 g_response。但是当我在网站上应用它时,它什么也没做。

from anticaptchaofficial.recaptchav2proxyless import *
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome(ChromeDriverManager().install())

driver.get('https://ferrarif430.blogabet.com/pick/17aecf79217c92f6041db4fb25997474')

solver = recaptchaV2Proxyless()
solver.set_verbose(1)
solver.set_key("KEY")
solver.set_website_url('https://thegeniustips.blogabet.com/pick/4848ea9854a93d80f7c680f5f3a1f2aa')
solver.set_website_key("6LczfBcTAAAAAJUj9xaEanJHszjBkgr9kQQgyNPI")

g_response = solver.solve_and_return_solution()
if g_response != 0:
    print ("g-response: "+g_response)
else:
    print ("task finished with error "+solver.error_code)
driver.execute_script('document.getElementById("g-recaptcha-response").innerHTML = "%s"' % g_response)

time.sleep(5)

WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[src^='https://www.google.com/recaptcha/api2/anchor']")))
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.recaptcha-checkbox-border"))).click()

它将响应应用于 Javascript,但它不执行任何操作。我做错什么了吗?

我还尝试使用 URL 访问它。

'https://thegeniustips.blogabet.com/pick/4848ea9854a93d80f7c680f5f3a1f2aa?g-recaptcha-response= + "g_response"'

但它返回了访问受限错误。

如何使用 g_response 访问此页面?它不一定是硒。即使是普通的 URL 请求也可以。

谢谢你。

ps - 如果您无法从链接中获得验证码,请发表评论。我会更新它

标签: javascriptpythonseleniumurlrecaptcha

解决方案


推荐阅读