diff --git a/README.md b/README.md index 97dbdc2..c51de3e 100644 --- a/README.md +++ b/README.md @@ -223,6 +223,18 @@ result = solver.keycaptcha(s_s_c_user_id=10, ``` + +### atbCAPTCHA +Use this method to solve atbCaptcha challenge. Returns a token to bypass captcha. +```python +result = solver.atb_captcha(app_id='af25e409b33d722a95e56a230ff8771c', + api_server='https://cap.aisecurius.com', + url='http://mysite.com/', + param1=..., ...) + +``` + + ### Capy Token-based method to bypass Capy puzzle captcha. ```python diff --git a/examples/atb_captcha.py b/examples/atb_captcha.py new file mode 100644 index 0000000..1cfb664 --- /dev/null +++ b/examples/atb_captcha.py @@ -0,0 +1,29 @@ +import sys +import os + +sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) + +from twocaptcha import TwoCaptcha + +# in this example we store the API key inside environment variables that can be set like: +# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS +# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows +# you can just set the API key directly to it's value like: +# api_key="1abc234de56fab7c89012d34e56fa7b8" + +api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY') + +solver = TwoCaptcha(api_key) + +try: + result = solver.atb_captcha( + app_id='af25e409b33d722a95e56a230ff8771c', + api_server='https://cap.aisecurius.com', + url='http://mysite.com/', + ) + +except Exception as e: + sys.exit(e) + +else: + sys.exit('result: ' + str(result)) diff --git a/examples/atb_captcha_options.py b/examples/atb_captcha_options.py new file mode 100644 index 0000000..379c7ce --- /dev/null +++ b/examples/atb_captcha_options.py @@ -0,0 +1,43 @@ +import sys +import os + +sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) + +from twocaptcha import TwoCaptcha + +# in this example we store the API key inside environment variables that can be set like: +# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS +# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows +# you can just set the API key directly to it's value like: +# api_key="1abc234de56fab7c89012d34e56fa7b8" + +api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY') + + +config = { + 'server': '2captcha.com', # can be also set to 'rucaptcha.com' + 'apiKey': api_key, + 'softId': 123, + # 'callback': 'https://your.site/result-receiver', # if set, sovler with just return captchaId, not polling API for the answer + 'defaultTimeout': 120, + 'recaptchaTimeout': 600, + 'pollingInterval': 10, + } + +solver = TwoCaptcha(**config) + +try: + result = solver.atb_captcha(app_id='af25e409b33d722a95e56a230ff8771c', + api_server='https://cap.aisecurius.com', + url='http://mysite.com/', + # proxy={ + # 'type': 'HTTPS', + # 'uri': 'login:password@IP_address:PORT' + # } + ) + +except Exception as e: + sys.exit(e) + +else: + sys.exit('result: ' + str(result)) diff --git a/examples/keycaptcha.py b/examples/keycaptcha.py index 22f19c1..ea14c20 100644 --- a/examples/keycaptcha.py +++ b/examples/keycaptcha.py @@ -14,7 +14,7 @@ api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY') solver = TwoCaptcha(api_key) -!!!! + try: result = solver.keycaptcha( s_s_c_user_id=15, diff --git a/tests/test_atb_captcha.py b/tests/test_atb_captcha.py new file mode 100644 index 0000000..021b3f6 --- /dev/null +++ b/tests/test_atb_captcha.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import unittest + +try: + from .abstract import AbstractTest +except ImportError: + from abstract import AbstractTest + + +class AtbCaptchaTest(AbstractTest): + + def test_all_params(self): + params = { + 'app_id': 'af25e409b33d722a95e56a230ff8771c', + 'api_server': 'https://cap.aisecurius.com', + 'url': 'http://mysite.com/' + } + + sends = { + 'method': 'atb_captcha', + 'app_id': 'af25e409b33d722a95e56a230ff8771c', + 'api_server': 'https://cap.aisecurius.com', + 'pageurl': 'http://mysite.com/' + } + + return self.send_return(sends, self.solver.atb_captcha, **params) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/twocaptcha/solver.py b/twocaptcha/solver.py index e8581f5..2cd875a 100755 --- a/twocaptcha/solver.py +++ b/twocaptcha/solver.py @@ -457,6 +457,26 @@ def lemin(self, captcha_id, div_id, url, **kwargs): method='lemin', **kwargs) return result + + def atb_captcha(self, app_id, api_server, url, **kwargs): + ''' + Wrapper for solving atbCAPTCHA + + Required: + app_id + api_server + url + + Optional params: + + + ''' + result = self.solve(app_id=app_id, + api_server=api_server, + url=url, + method='atb_captcha', + **kwargs) + return result def turnstile(self, sitekey, url, **kwargs):