2captcha / 2captcha-python

Python 3 package for easy integration with the API of 2captcha captcha solving service to bypass recaptcha, hcaptcha, funcaptcha, geetest and solve any other captchas.
https://2captcha.com
MIT License
495 stars 93 forks source link

AttributeError: 'TwoCaptcha' object has no attribute 'recaptcha' #69

Closed WenhaoYou1 closed 6 months ago

WenhaoYou1 commented 6 months ago

I update both TwoCaptcha and 2captcha-python to the latest version. Show my code below: solver = TwoCaptcha(api_key) try: result = solver.recaptcha(sitekey=site_key, url=pageurl) print("Recaptcha Answer:", result['code'])

except Exception as e: print('Error:', e)

Thanks for your help.

codingMiiichael commented 6 months ago

I also faced the same prob

WenhaoYou1 commented 6 months ago
I solved this problem by using requests. Here is my code:

api_endpoint = 'http://2captcha.com/in.php'
result_endpoint = 'http://2captcha.com/res.php'

payload = {
    'method': 'userrecaptcha',
    'googlekey': site_key,
    'key': api_key,
    'pageurl': pageurl,
    'json': 1
}
response = requests.post(api_endpoint, data=payload)
response_data = response.json()

if response_data.get('status') == 1:
    request_id = response_data.get('request')
    time.sleep(20)  #
    result = requests.get(result_endpoint, params={
        'key': api_key,
        'action': 'get',
        'id': request_id,
        'json': 1
    })
    result_data = result.json()