diff --git a/README.md b/README.md index 97dbdc2..cbd2d60 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,9 @@ The easiest way to quickly integrate [2Captcha] captcha solving service into you - [Canvas](#canvas) - [ClickCaptcha](#clickcaptcha) - [Rotate](#rotate) + - [MTCaptcha](#mtcaptcha) + - [Friendly Captcha](#friendly_captcha) + - [Cutcaptcha](#cutcaptcha) - [Other methods](#other-methods) - [send / getResult](#send--getresult) - [balance](#balance) @@ -253,6 +256,32 @@ This method can be used to solve a captcha that asks to rotate an object. Mostly result = solver.rotate('path/to/captcha.jpg', param1=..., ...) ``` +### MTCaptcha +Use this method to solve MTCaptcha and obtain a token to bypass the protection. +```python +result = solver.mtcaptcha(sitekey='MTPublic-KzqLY1cKH', + url='https://2captcha.com/demo/mtcaptcha', + param1=..., ...) +``` + +### Friendly Captcha +Friendly Captcha solving method. Returns a token. +```python +result = solver.friendly_captcha(sitekey='FCMGEMUD2KTDSQ5H', + url='https://friendlycaptcha.com/demo', + param1=..., ...) +``` + +### Cutcaptcha +Use this method to solve Cutcaptcha. Returns the response in JSON. +```python +result = solver.cutcaptcha(misery_key='ad52c87af17e2ec09b8d918c9f00416b1cb8c320', + apikey='SAs61IAI', + url='https://mysite.com/page/with/cutcaptcha', + param1=..., ...) +``` + + ## Other methods ### send / getResult diff --git a/examples/cutcaptcha.py b/examples/cutcaptcha.py new file mode 100644 index 0000000..11acedf --- /dev/null +++ b/examples/cutcaptcha.py @@ -0,0 +1,30 @@ +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.cutcaptcha( + misery_key='ad52c87af17e2ec09b8d918c9f00416b1cb8c320', + apikey='SAs61IAI', + url='https://mysite.com/page/with/cutcaptcha', + ) + +except Exception as e: + sys.exit(e) + +else: + sys.exit('result: ' + str(result)) \ No newline at end of file diff --git a/examples/cutcaptcha_options.py b/examples/cutcaptcha_options.py new file mode 100644 index 0000000..a1cb2c5 --- /dev/null +++ b/examples/cutcaptcha_options.py @@ -0,0 +1,42 @@ +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.cutcaptcha(misery_key='ad52c87af17e2ec09b8d918c9f00416b1cb8c320', + apikey='SAs61IAI', + url='https://mysite.com/page/with/cutcaptcha' + # proxy={ + # 'type': 'HTTPS', + # 'uri': 'login:password@IP_address:PORT' + # } + ) + +except Exception as e: + sys.exit(e) + +else: + sys.exit('result: ' + str(result)) \ No newline at end of file diff --git a/examples/friendly_captcha.py b/examples/friendly_captcha.py new file mode 100644 index 0000000..29d1a92 --- /dev/null +++ b/examples/friendly_captcha.py @@ -0,0 +1,28 @@ +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.friendly_captcha( + sitekey='FCMGEMUD2KTDSQ5H', + url='https://friendlycaptcha.com/demo', + ) + +except Exception as e: + sys.exit(e) + +else: + sys.exit('result: ' + str(result)) \ No newline at end of file diff --git a/examples/friendly_captcha_options.py b/examples/friendly_captcha_options.py new file mode 100644 index 0000000..9203ef5 --- /dev/null +++ b/examples/friendly_captcha_options.py @@ -0,0 +1,41 @@ +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.friendly_captcha(sitekey='FCMGEMUD2KTDSQ5H', + url='https://friendlycaptcha.com/demo', + # proxy={ + # 'type': 'HTTPS', + # 'uri': 'login:password@IP_address:PORT' + # } + ) + +except Exception as e: + sys.exit(e) + +else: + sys.exit('result: ' + str(result)) \ No newline at end of file diff --git a/examples/mtcaptcha.py b/examples/mtcaptcha.py new file mode 100644 index 0000000..d1aa862 --- /dev/null +++ b/examples/mtcaptcha.py @@ -0,0 +1,28 @@ +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.mtcaptcha( + sitekey='MTPublic-KzqLY1cKH', + url='https://2captcha.com/demo/mtcaptcha', + ) + +except Exception as e: + sys.exit(e) + +else: + sys.exit('result: ' + str(result)) \ No newline at end of file diff --git a/examples/mtcaptcha_options.py b/examples/mtcaptcha_options.py new file mode 100644 index 0000000..0935fa6 --- /dev/null +++ b/examples/mtcaptcha_options.py @@ -0,0 +1,41 @@ +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.mtcaptcha(sitekey='MTPublic-KzqLY1cKH', + url='https://2captcha.com/demo/mtcaptcha', + # proxy={ + # 'type': 'HTTPS', + # 'uri': 'login:password@IP_address:PORT' + # } + ) + +except Exception as e: + sys.exit(e) + +else: + sys.exit('result: ' + str(result)) \ No newline at end of file diff --git a/tests/test_cutcaptcha.py b/tests/test_cutcaptcha.py new file mode 100644 index 0000000..f6cd10f --- /dev/null +++ b/tests/test_cutcaptcha.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import unittest + +try: + from .abstract import AbstractTest +except ImportError: + from abstract import AbstractTest + + +class CutcaptchaTest(AbstractTest): + + def test_all_params(self): + params = { + 'misery_key': 'ad52c87af17e2ec09b8d918c9f00416b1cb8c320', + 'apikey': 'SAs61IAI', + 'url': 'https://www.site.com/page/', + } + + sends = { + 'method': 'cutcaptchaĐ°', + 'api_key': 'SAs61IAI', + 'misery_key': 'ad52c87af17e2ec09b8d918c9f00416b1cb8c320', + 'pageurl': 'https://www.site.com/page/', + } + + return self.send_return(sends, self.solver.cutcaptcha, **params) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_friendly_captcha.py b/tests/test_friendly_captcha.py new file mode 100644 index 0000000..21ebdca --- /dev/null +++ b/tests/test_friendly_captcha.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +import unittest + +try: + from .abstract import AbstractTest +except ImportError: + from abstract import AbstractTest + + +class FriendlyCaptchaTest(AbstractTest): + + def test_all_params(self): + params = { + 'sitekey': 'FCMGEMUD2KTDSQ5H', + 'url': 'https://friendlycaptcha.com/demo', + } + + sends = { + 'method': 'friendly_captcha', + 'sitekey': 'FCMGEMUD2KTDSQ5H', + 'pageurl': 'https://friendlycaptcha.com/demo', + } + + return self.send_return(sends, self.solver.friendly_captcha, **params) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_mtcaptcha.py b/tests/test_mtcaptcha.py new file mode 100644 index 0000000..09cc49d --- /dev/null +++ b/tests/test_mtcaptcha.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +import unittest + +try: + from .abstract import AbstractTest +except ImportError: + from abstract import AbstractTest + + +class MTCaptchaTest(AbstractTest): + + def test_all_params(self): + params = { + 'sitekey': 'MTPublic-KzqLY1cKH', + 'url': 'https://2captcha.com/demo/mtcaptcha', + } + + sends = { + 'method': 'mt_captcha', + 'sitekey': 'MTPublic-KzqLY1cKH', + 'pageurl': 'https://2captcha.com/demo/mtcaptcha', + } + + return self.send_return(sends, self.solver.mtcaptcha, **params) + + +if __name__ == '__main__': + unittest.main() diff --git a/twocaptcha/solver.py b/twocaptcha/solver.py index e8581f5..8078e5e 100755 --- a/twocaptcha/solver.py +++ b/twocaptcha/solver.py @@ -503,7 +503,67 @@ def amazon_waf(self, sitekey, iv, context, url, **kwargs): return result + def mtcaptcha(self, sitekey, url, **kwargs): + ''' + Wrapper for solving MTCaptcha + + Required: + sitekey + url + + Optional params: + softId + callback + proxy = {'type': 'HTTPS', 'uri': 'login:password@IP_address:PORT'}) + ''' + + result = self.solve(sitekey=sitekey, + url=url, + method='mt_captcha', + **kwargs) + return result + + def friendly_captcha(self, sitekey, url, **kwargs): + ''' + Wrapper for solving Friendly Captcha + Required: + sitekey + url + + Optional params: + softId + callback + proxy = {'type': 'HTTPS', 'uri': 'login:password@IP_address:PORT'}) + ''' + + result = self.solve(sitekey=sitekey, + url=url, + method='friendly_captcha', + **kwargs) + return result + + def cutcaptcha(self, misery_key, apikey, url, **kwargs): + ''' + Wrapper for solving Friendly Captcha + + Required: + misery_key + apikey + url + + Optional params: + softId + callback + proxy = {'type': 'HTTPS', 'uri': 'login:password@IP_address:PORT'}) + ''' + + result = self.solve(misery_key=misery_key, + api_key=apikey, + url=url, + method='cutcaptcha', + **kwargs) + return result def solve(self, timeout=0, polling_interval=0, **kwargs): '''