Captcha solveing with requests selenium, 2captcha and python

Moskil

New member
#1
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.

Code:
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:])