Problem to solve reCaptcha

Evandro

New member
I'm trying to solve a reCaptcha pje.trt6.jus.br/certidoes/trabalhista/emissao.

I've already read this post and used this code and they heleped me to in handle the reCaptcha others websites , however I can't solve the reCapatcha in this site pje.trt6.jus.br/certidoes/trabalhista/emissao.

I've followed every steps, found out the callback function and put the response on it, but it returned invalid reCaptcha.

This is the response that I receive:
1606010498429.png


And here is the error in console:

JavaScript:
ERROR
{…}
error: Object { identificadorRequisicao: "10355f97-7272-4cc1-ac86-d0e03540c8c1", codigoErro: "CER-017", mensagem: "Unexpected error invalid-input-response when checking CAPTCHA" }
headers: Object { normalizedNames: Map(15), lazyUpdate: null, lazyInit: null, … }

message: "Http failure response for https://pje.trt6.jus.br/pje-certidoes-api/api/certidoes/trabalhistas/emissao: 500 Internal Server Error"

name: "HttpErrorResponse"

ok: false

status: 500

statusText: "Internal Server Error"

url: "https://pje.trt6.jus.br/pje-certidoes-api/api/certidoes/trabalhistas/emissao"

<prototype>: {…



Here is the callback function:
1606010316333.png


Here is a snippet of my code:

Python:
def solve_recaptcha(site):

    solver = TwoCaptcha('***')
    g_recaptcha = solver.recaptcha(sitekey='6LdiJtkUAAAAAIKaob0HxASzZKlfsZxt5QQE7gxn', url=site)
    print(g_recaptcha)
    return g_recaptcha['code']

def crawler():
    site = 'https://pje.trt6.jus.br/certidoes/trabalhista/emissao'
    g_response = solve_recaptcha(site)
    driver.execute_script("""document.getElementById("g-recaptcha-response").innerHTML = arguments[0]""", g_response)
    driver.execute_script("""___grecaptcha_cfg.clients[0].l.l.callback("{}")""", g_response)
    WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.XPATH, "//span[contains(text(), 'Emitir')]"))).click()


Please, someone can help me to solve this reCaptcha from hell.
 
Last edited by a moderator:

agmeadows

New member
Try this for your code:
Python:
self.driver.execute_script("document.getElementById('g-recaptcha-response').innerHTML = '{0}';".format(g_response))
self.driver.execute_script("___grecaptcha_cfg_client[0].l.l.callback('{}')".format(g_response))

You shouldn't need the click at the end because the callback will submit the form
 

Evandro

New member
Try this for your code:
Python:
self.driver.execute_script("document.getElementById('g-recaptcha-response').innerHTML = '{0}';".format(g_response))
self.driver.execute_script("___grecaptcha_cfg_client[0].l.l.callback('{}')".format(g_response))

You shouldn't need the click at the end because the callback will submit the form


Thank you, it's working now!!