Home:ALL Converter>Captcha solveing with requests selenium, 2captcha and python

Captcha solveing with requests selenium, 2captcha and python

Ask Time:2021-06-07T01:33:30         Author:Sebastian216

Json Formatter

I'm using 2captcha and selenium, I get a code generated to solve but I'm not able to submit it. I tried this solution Python + Selenium + 2Captcha but I can't manage to make it click.

resp = requests.get(url)

if resp.text[0:2] != 'OK':
    quit('Service error. Error code:' + resp.text)
captcha_id = resp.text[3:]

fetch_url = "http://2captcha.com/res.php?key="+ service_key + "&action=get&id=" + captcha_id

for i in range(1, 10):
    sleep(5) # wait 5 sec.
    resp = requests.get(fetch_url)
    if resp.text[0:2] == 'OK':
        break

driver.execute_script('var element=document.getElementById("g-recaptcha-response"); element.style.display="";')
driver.execute_script('document.getElementById("g-recaptcha-response").innerHTML = arguments[0]', resp.text[3:])
driver.execute_script('onSubmit(arguments[0])', resp.text[3:])

Author:Sebastian216,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/67861924/captcha-solveing-with-requests-selenium-2captcha-and-python
yy