From 554db085f5ccaf5a6db0e0fe33836d1338fa88c7 Mon Sep 17 00:00:00 2001 From: Maxim S Date: Wed, 28 Aug 2024 15:35:33 +0200 Subject: [PATCH 1/5] - Added cybersiara method to solver.py - Added cybersiara.py to examples - Added test_cybersiara.py to tests - Added a description of the cybersiara method to README.md Signed-off-by: Maxim S --- README.md | 12 ++++++++++++ examples/cybersiara.py | 30 ++++++++++++++++++++++++++++++ tests/test_cybersiara.py | 32 ++++++++++++++++++++++++++++++++ twocaptcha/solver.py | 10 ++++++++++ 4 files changed, 84 insertions(+) create mode 100644 examples/cybersiara.py create mode 100644 tests/test_cybersiara.py diff --git a/README.md b/README.md index d8c05cd..3e34117 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Examples of API requests for different captcha types are available on the [Pytho - [Friendly Captcha](#friendly-captcha) - [Cutcaptcha](#cutcaptcha) - [Tencent](#tencent) + - [CyberSiARA](#cybersiara) - [Other methods](#other-methods) - [send / get_result](#send--get_result) - [balance](#balance) @@ -407,6 +408,17 @@ result = solver.tencent(app_id="197326679", param1=..., ...) ``` +### CyberSiARA + +[API method description.](https://2captcha.com/2captcha-api#cybersiara) + +Use this method to solve CyberSiARA. Returns a token. +```python +result = solver.cybersiara(master_url_id='tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv', + pageurl='https://demo.mycybersiara.com/', + param1=..., ...) +``` + ## Other methods ### send / get_result diff --git a/examples/cybersiara.py b/examples/cybersiara.py new file mode 100644 index 0000000..a8604c6 --- /dev/null +++ b/examples/cybersiara.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.cybersiara( + master_url_id='tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv', + pageurl='https://demo.mycybersiara.com/', + userAgent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36', + ) + +except Exception as e: + sys.exit(e) + +else: + sys.exit('result: ' + str(result)) \ No newline at end of file diff --git a/tests/test_cybersiara.py b/tests/test_cybersiara.py new file mode 100644 index 0000000..0404cf8 --- /dev/null +++ b/tests/test_cybersiara.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +import unittest + +try: + from .abstract import AbstractTest +except ImportError: + from abstract import AbstractTest + + +class CybersiaraTest(AbstractTest): + + def test_all_params(self): + params = { + 'master_url_id': 'tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv', + 'pageurl': 'https://demo.mycybersiara.com/', + 'userAgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36', + } + + sends = { + 'method': 'cybersiara', + 'master_url_id': 'tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv', + 'pageurl': 'https://demo.mycybersiara.com/', + 'userAgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36', + } + + return self.send_return(sends, self.solver.cybersiara, **params) + + +if __name__ == '__main__': + unittest.main() + diff --git a/twocaptcha/solver.py b/twocaptcha/solver.py index f460baf..fa6d2f3 100755 --- a/twocaptcha/solver.py +++ b/twocaptcha/solver.py @@ -810,6 +810,16 @@ def cutcaptcha(self, misery_key, apikey, url, **kwargs): **kwargs) return result + def cybersiara(self, master_url_id, pageurl, userAgent, **kwargs): + + result = self.solve(method='cybersiara', + master_url_id=master_url_id, + pageurl=pageurl, + userAgent=userAgent, + **kwargs) + + return result + def solve(self, timeout=0, polling_interval=0, **kwargs): '''Sends captcha, receives result. From 8161da3198fe4b4df8e3efe4c75077ddeb1cf06a Mon Sep 17 00:00:00 2001 From: dzmitry-duboyski Date: Thu, 29 Aug 2024 19:22:47 +0400 Subject: [PATCH 2/5] Update keywords --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bed8bd4..686c902 100644 --- a/setup.py +++ b/setup.py @@ -36,6 +36,6 @@ def get_version(): '2captcha', 'captcha', 'api', 'captcha solver', 'reCAPTCHA', 'hCaptcha', 'FunCaptcha', 'Geetest', 'image captcha', 'Coordinates', 'Click Captcha', 'Geetest V4', 'Lemin captcha', 'Amazon WAF', 'Cloudflare Turnstile', - 'Capy Puzzle', 'MTCaptcha', 'Friendly Captcha', 'Tencent'], + 'Capy Puzzle', 'MTCaptcha', 'Friendly Captcha', 'Tencent', 'cybersiara'], python_requires='>=3.6', test_suite='tests') From 8a79a4d585f926bda99956f26d0b10192e25b0e4 Mon Sep 17 00:00:00 2001 From: dzmitry-duboyski Date: Thu, 29 Aug 2024 19:26:26 +0400 Subject: [PATCH 3/5] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e34117..181da2b 100644 --- a/README.md +++ b/README.md @@ -416,6 +416,7 @@ Use this method to solve CyberSiARA. Returns a token. ```python result = solver.cybersiara(master_url_id='tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv', pageurl='https://demo.mycybersiara.com/', + userAgent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36', param1=..., ...) ``` @@ -492,7 +493,7 @@ except TimeoutException as e: ## Proxies You can pass your proxy as an additional argument for the following methods: recaptcha, funcaptcha, geetest, geetest v4, hcaptcha, -keycaptcha, capy puzzle, lemin, atbcaptcha, turnstile, amazon waf, mtcaptcha, friendly captcha, cutcaptcha. +keycaptcha, capy puzzle, lemin, atbcaptcha, turnstile, amazon waf, mtcaptcha, friendly captcha, cutcaptcha, cybersiara. The proxy will be forwarded to the API to solve the captcha. From c171b1729de9cdd6862a39515e85964e43b6c670 Mon Sep 17 00:00:00 2001 From: Maxim S Date: Thu, 29 Aug 2024 17:47:51 +0200 Subject: [PATCH 4/5] - Added documentation for the cybersiara method to solver.py Signed-off-by: Maxim S --- twocaptcha/solver.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/twocaptcha/solver.py b/twocaptcha/solver.py index fa6d2f3..7fab25b 100755 --- a/twocaptcha/solver.py +++ b/twocaptcha/solver.py @@ -811,7 +811,19 @@ def cutcaptcha(self, misery_key, apikey, url, **kwargs): return result def cybersiara(self, master_url_id, pageurl, userAgent, **kwargs): + '''Wrapper for solving CyberSiARA captcha. + Parameters + __________ + master_url_id : str + TThe value of the MasterUrlId parameter from the request to API/CyberSiara/GetCyberSiara. + pageurl : str + Full URL of the page with captcha. + userAgent : str + User-Agent of your browser. + proxy : dict, optional + {'type': 'HTTPS', 'uri': 'login:password@IP_address:PORT'}. + ''' result = self.solve(method='cybersiara', master_url_id=master_url_id, pageurl=pageurl, From 1b130c01770b335135b6f8034027ffec5c92b698 Mon Sep 17 00:00:00 2001 From: dzmitry-duboyski Date: Fri, 30 Aug 2024 12:23:23 +0400 Subject: [PATCH 5/5] Typo --- twocaptcha/solver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/twocaptcha/solver.py b/twocaptcha/solver.py index 7fab25b..6f161d7 100755 --- a/twocaptcha/solver.py +++ b/twocaptcha/solver.py @@ -816,7 +816,7 @@ def cybersiara(self, master_url_id, pageurl, userAgent, **kwargs): Parameters __________ master_url_id : str - TThe value of the MasterUrlId parameter from the request to API/CyberSiara/GetCyberSiara. + The value of the MasterUrlId parameter from the request to API/CyberSiara/GetCyberSiara. pageurl : str Full URL of the page with captcha. userAgent : str