2captcha / 2captcha-python

Python 3 package for easy integration with the API of 2captcha captcha solving service to bypass recaptcha, hcaptcha, сloudflare turnstile, funcaptcha, geetest and solve any other captchas.
https://pypi.org/project/2captcha-python
MIT License
532 stars 91 forks source link

Support on AWS Lambda #52

Closed Mamamouchi closed 1 year ago

Mamamouchi commented 1 year ago

Hello, I've tried to resolve captcha on AWS Lambda and it does not working. There is no message and it don't execute the sequence...

def resolve_captcha(self, image_url):
        result = None
        random_image_path = '/tmp/' + generate_random_string(length=10) + ".png"
        with urlopen(image_url) as url:
            with open(random_image_path, 'wb') as f:
                f.write(url.read())
        solver = TwoCaptcha('APIKEY_2CAPTCHA')
        try:
            result = solver.normal(random_image_path)
            os.remove(random_image_path)
        except ValidationException as e:
            # invalid parameters passed
            print(e)
            os.remove(random_image_path)
        except NetworkException as e:
            # network error occurred
            print(e)
            os.remove(random_image_path)
        except ApiException as e:
            # api respond with error
            print(e)
            os.remove(random_image_path)
        except TimeoutException as e:
            # captcha is not solved so far
            print(e)
            os.remove(random_image_path)
        return result

Do you have some tips for this issue (it work locally). Thank's in advance.

kratzky commented 1 year ago

Could you please describe in more details what do you mean on does not working? Are there any exceptions, errors, etc? What happens when you run the code?