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)
1 Answer 1
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
Comments
Explore related questions
See similar questions with these tags.