Python ws Selenium how to solved reCAPTCHA invisible

lSteve

New member
#1
Python + Selenium pls help me solved recaptcha invisible on the site instacart.com, when I log in.

Code for solving captcha. Used rucaptcha mirror (2captcha). I am successfully getting response code, but I can't embed it on the site
Code:
def captcha_solution(site_key: str, url: str):
    key = "api_key"  # api key
    id = requests.post("https://rucaptcha.com/in.php", params={
        "key": key,
        "method": "userrecaptcha",
        "googlekey": site_key,
        "pageurl": url,
        "json": 1
    })

    capt_id = id.json()["request"]

    while True:
        response = requests.get("https://rucaptcha.com/res.php", params={
            "key": key,
            "action": "get",
            "id": capt_id
        })

        if response.text == 'CAPCHA_NOT_READY':
            time.sleep(3)
        else:
            break

    return response.text.split("|")[-1]

###########function call##############

site_key = '6LfgstgZAAAAAO_TzxqxqR8E8Fu16VqIs1mBtAKH'
url = 'https://www.instacart.com'
captcha = captcha_solution(site_key, url) # get captcha
browser.execute_script('document.getElementById("g-recaptcha-response").innerHTML = "%s"' % (captcha)) # here I can not insert response to the site
Thank you for your time