首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python被反Captcha解决,但不能传递响应

Python被反Captcha解决,但不能传递响应
EN

Stack Overflow用户
提问于 2021-07-16 07:06:21
回答 1查看 465关注 0票数 1

我正在使用反captcha api来解决。我的captcha是通过反captcha来解决,并在解决captcha之后获得captcha响应。我使用这个driver.execute_script("document.getElementById('g-recaptcha-response').innerHTML = '" + g_response + "';")来传递captcha响应,但是没有发生任何事情,请参见图:

captcha正在解决,但我需要通过传递captcha响应来单击“验证”按钮,这样我就可以转到下一页。这是我的代码:

代码语言:javascript
复制
email = driver.find_element_by_xpath("")
email.send_keys('')
password = driver.find_element_by_xpath("")
password.send_keys('')
button = driver.find_element_by_css_selector('')
button.click()


    solver = recaptchaV2Proxyless()
    solver.set_verbose(1)
    solver.set_key("my api key ")
    solver.set_website_url("website url")
    solver.set_website_key("captcha site key")
    
    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)
    
    
    time.sleep(3)
    
    driver.execute_script("document.getElementById('g-recaptcha-response').innerHTML = '" + g_response + "';") #I am using this for pass captcha response but captcha is solving but response not passing
EN

回答 1

Stack Overflow用户

发布于 2022-09-16 09:38:51

您需要将g-响应传递给文本区域,然后单击submit按钮:

代码语言:javascript
复制
solver = recaptchaV2Proxyless()
solver.set_verbose(1)
solver.set_key("my api key ")
solver.set_website_url("website url")
solver.set_website_key("captcha site key")        
g_response = solver.solve_and_return_solution()

if g_response != 0:
    print ("g-response: "+g_response)  
    driver.execute_script(f'document.getElementsByName("gRecaptchaResponse").innerHTML="{g_response}"')
    driver.find_element(By.XPATH, '//*[@id="recaptcha-demo-submit"]').click() # xpath of textarea submit button
else:
    print ("task finished with error "+solver.error_code)   
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68404840

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档