[Python] How to subbimit g-recaptcha-response using python

Discussão em 'Python' iniciado por Stack, Março 28, 2025.

  1. Stack

    Stack Membro Participativo

    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.com/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)

    Continue reading...

Compartilhe esta Página