最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - How to subbimit g-recaptcha-response using python - Stack Overflow

programmeradmin5浏览0评论

I need to make several queries on the website below (for each query I will download a spreadsheet).

.pu?operation=localizar

I am using selenium to press the appropriate buttons, however, the captcha is making it impossible to continue with the query.

I'm using an api to solve the captcha but I'm not able to send the response back.

Below is a part of the code.

solver = recaptchaV2Proxyless()
solver.set_verbose(1)
solver.set_key('xxxx')
solver.set_website_url(link)
solver.set_website_key(site_key) 

resposta = solver.solve_and_return_solution()  # it works

if resposta != 0:
    print(resposta)
    navegador.execute_script(f"document.getElementById('g-recaptcha-response').innerHTML = '{resposta}'")  % apparently it works

    WebDriverWait(navegador, 3).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[name^='a-'][src^='?']")))

    # Attempts, but none worked
    #navegador.find_element(By.ID, 'recaptcha-demo-submit').click()
    #navegador.find_element(By.CLASS_NAME, 'recaptcha-checkbox-border').click()
    #navegador.find_element(By.ID, 'g-recaptcha-response-submit').click()
    #navegador.find_element(By.ID, 'submit').click()

else:
    print(solver.err_string)




I need to make several queries on the website below (for each query I will download a spreadsheet).

https://www.fnde.gov.br/sigpcadm/sistema.pu?operation=localizar

I am using selenium to press the appropriate buttons, however, the captcha is making it impossible to continue with the query.

I'm using an api to solve the captcha but I'm not able to send the response back.

Below is a part of the code.

solver = recaptchaV2Proxyless()
solver.set_verbose(1)
solver.set_key('xxxx')
solver.set_website_url(link)
solver.set_website_key(site_key) 

resposta = solver.solve_and_return_solution()  # it works

if resposta != 0:
    print(resposta)
    navegador.execute_script(f"document.getElementById('g-recaptcha-response').innerHTML = '{resposta}'")  % apparently it works

    WebDriverWait(navegador, 3).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[name^='a-'][src^='https://www.google/recaptcha/api2/anchor?']")))

    # Attempts, but none worked
    #navegador.find_element(By.ID, 'recaptcha-demo-submit').click()
    #navegador.find_element(By.CLASS_NAME, 'recaptcha-checkbox-border').click()
    #navegador.find_element(By.ID, 'g-recaptcha-response-submit').click()
    #navegador.find_element(By.ID, 'submit').click()

else:
    print(solver.err_string)




Share Improve this question edited Mar 28 at 8:06 jottbe 4,5312 gold badges18 silver badges35 bronze badges asked Mar 27 at 0:02 Andre AlencarAndre Alencar 111 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

Try to set g-recaptcha-response isn’t always enough i think. some sites require an extra verification step. Try this after setting the response:

navegador.execute_script("document.getElementById('g-recaptcha-response').value = arguments[0];", resposta)
navegador.execute_script("document.getElementById('g-recaptcha-response').dispatchEvent(new Event('change'));")

not all captcha solver work the same way. I had trouble with a few until I switched to one that handled reCAPTCHA more reliably. CapSolver worked well for me just for reference

发布评论

评论列表(0)

  1. 暂无评论