How can I input a recapcha key into a costum site using selenium?

Rediker

New member
I am trying to solve a captcha using api from 2cap. It works to get the captcha key but i am stuck. I dont know how to "input" it into recaptcha. I would be very happy when somebody can send me an example of how it works in exact this site. The person thats help me solving will get some money on paypal (only if the person wants) and I am giving this money cause I get money for that project so its only fair. And btw sorry for my english.

MY CODE:
Code:
# Solve reCaptcha V2 with Selenium Python Using 2captcha
from selenium import webdriver
import requests, time

API_KEY = "MYAPIKEY"
data_sitekey = '6Ldu0RETAAAAAFRTCzycHREmOKJzX3ZCutyhHjEc'
page_url ='https://www.o2.co.uk/shop/sim-cards/pay-as-you-go/delivery?planId=1a209061-ba66-47c9-9387-1af8ce8dd0be'

def Solver():
    driver = webdriver.Chrome()
    driver.get(page_url)
    u1 = f"https://2captcha.com/in.php?key={API_KEY}&method=userrecaptcha&googlekey={data_sitekey}&pageurl={page_url}&json=1&invisible=1"
    r1 = requests.get(u1)
    print(r1.json())
    rid = r1.json().get("request")
    u2 = f"https://2captcha.com/res.php?key={API_KEY}&action=get&id={int(rid)}&json=1"
    time.sleep(5)
    while True:
        r2 = requests.get(u2)
        print(r2.json())
        if r2.json().get("status") == 1:
            form_tokon = r2.json().get("request")
            break
        time.sleep(5)
    time.sleep(999)

if __name__ == '__main__':
    Solver()
 

jhnprnc

New member
Hi !
Maybe you should try something like this code, it will do the same as in this video https://2captcha.com/p/recaptcha_v2 at 3:20.
Just make sure to remplace by the correct xpath where you have the 'display:none' attribute.

Python:
attribute = driver.find_element_by_xpath('XPATH_of_displaynone')
driver.execute_script("arguments[0].setAttribute('style', 'width: 250px; height: 40px; border: 1px solid rgb(193, 193, 193); margin: 10px 25px; padding: 0px; resize: none;')", attribute)
attribute.send_keys(form_tokon)