diff --git a/docs/conf.py b/docs/conf.py index b6c139e0..64a0643b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -6,6 +6,7 @@ from python_rucaptcha import ( core, control, + prosopo, tencent, gee_test, hcaptcha, diff --git a/docs/index.rst b/docs/index.rst index a5b1552a..f53e67f4 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -50,6 +50,7 @@ Check our other projects here - `RedPandaDev group =2.32.0 # not directly required, pinned by Snyk to avoid a vulnerability urllib3>=2.2.2 # not directly required, pinned by Snyk to avoid a vulnerability diff --git a/requirements.style.txt b/requirements.style.txt index 514ac380..8fbb0b9b 100644 --- a/requirements.style.txt +++ b/requirements.style.txt @@ -1,4 +1,4 @@ # codestyle -isort==5.* -black==24.10.0 +isort==6.* +black==25.1.0 autoflake==2.* diff --git a/src/python_rucaptcha/__version__.py b/src/python_rucaptcha/__version__.py index 221cd932..123dd5c0 100644 --- a/src/python_rucaptcha/__version__.py +++ b/src/python_rucaptcha/__version__.py @@ -1 +1 @@ -__version__ = "6.3.1" +__version__ = "6.3.2" diff --git a/src/python_rucaptcha/atb_captcha.py b/src/python_rucaptcha/atb_captcha.py index d3efd0a6..42fd0607 100644 --- a/src/python_rucaptcha/atb_captcha.py +++ b/src/python_rucaptcha/atb_captcha.py @@ -71,6 +71,7 @@ def __init__( Notes: https://rucaptcha.com/api-docs/atb-captcha + https://2captcha.com/api-docs/atb-captcha """ super().__init__(method=method, *args, **kwargs) diff --git a/src/python_rucaptcha/control.py b/src/python_rucaptcha/control.py index 7e635ac9..040b5951 100644 --- a/src/python_rucaptcha/control.py +++ b/src/python_rucaptcha/control.py @@ -55,10 +55,15 @@ def __init__( Notes: https://rucaptcha.com/api-docs/get-balance + https://rucaptcha.com/api-docs/report-correct + https://rucaptcha.com/api-docs/report-incorrect + https://2captcha.com/api-docs/get-balance + https://2captcha.com/api-docs/report-correct + https://2captcha.com/api-docs/report-incorrect """ diff --git a/src/python_rucaptcha/core/enums.py b/src/python_rucaptcha/core/enums.py index cdf9a34a..9d1aa9a1 100644 --- a/src/python_rucaptcha/core/enums.py +++ b/src/python_rucaptcha/core/enums.py @@ -159,3 +159,8 @@ class TencentEnm(str, MyEnum): class atbCaptchaEnm(str, MyEnum): AtbCaptchaTask = "AtbCaptchaTask" AtbCaptchaTaskProxyless = "AtbCaptchaTaskProxyless" + + +class ProsopoEnm(str, MyEnum): + ProsopoTask = "ProsopoTask" + ProsopoTaskProxyless = "ProsopoTaskProxyless " diff --git a/src/python_rucaptcha/prosopo.py b/src/python_rucaptcha/prosopo.py new file mode 100644 index 00000000..2c055b94 --- /dev/null +++ b/src/python_rucaptcha/prosopo.py @@ -0,0 +1,108 @@ +from typing import Union + +from .core.base import BaseCaptcha +from .core.enums import ProsopoEnm + + +class Prosopo(BaseCaptcha): + def __init__( + self, + websiteURL: str, + websiteKey: str, + method: Union[str, ProsopoEnm] = ProsopoEnm.ProsopoTaskProxyless, + *args, + **kwargs, + ): + """ + The class is used to work with Prosopo. + + Args: + rucaptcha_key: User API key + websiteURL: The full URL of target web page where the captcha is loaded. + We do not open the page, not a problem if it is available + only for authenticated users + websiteKey: The value of `siteKey` parameter found on the page. + method: Captcha type + + Examples: + >>> Prosopo(rucaptcha_key="aa9011f31111181111168611f1151122", + ... websiteURL="https://www.example.com/", + ... websiteKey="5EPQoMZEDc5LpN7gtxMMzYPTzA6UeWqL2stk1rso9gy4Ahqt", + ... method=ProsopoEnm.ProsopoTaskProxyless.value, + ... ).captcha_handler() + { + "errorId":0, + "status":"ready", + "solution":{ + "token": "0x00016c68747470733950547a4136", + }, + "cost":"0.00299", + "ip":"1.2.3.4", + "createTime":1692863536, + "endTime":1692863556, + "solveCount":1, + "taskId":75190409731 + } + + >>> await Prosopo(rucaptcha_key="aa9011f31111181111168611f1151122", + ... websiteURL="https://www.example.com/", + ... websiteKey="5EPQoMZEDc5LpN7gtxMMzYPTzA6UeWqL2stk1rso9gy4Ahqt", + ... method=ProsopoEnm.ProsopoTaskProxyless.value, + ... ).aio_captcha_handler() + { + "errorId":0, + "status":"ready", + "solution":{ + "token": "0x00016c68747470733950547a4136", + }, + "cost":"0.00299", + "ip":"1.2.3.4", + "createTime":1692863536, + "endTime":1692863556, + "solveCount":1, + "taskId":75190409731 + } + + Returns: + Dict with full server response + + Notes: + https://rucaptcha.com/api-docs/prosopo-procaptcha + + https://rucaptcha.com/api-docs/prosopo-procaptcha + """ + super().__init__(method=method, *args, **kwargs) + + self.create_task_payload["task"].update({"websiteURL": websiteURL, "websiteKey": websiteKey}) + + # check user params + if method not in ProsopoEnm.list_values(): + raise ValueError(f"Invalid method parameter set, available - {ProsopoEnm.list_values()}") + + def captcha_handler(self, **kwargs) -> dict: + """ + Sync solving method + + Args: + kwargs: additional params for `requests` library + + Returns: + Dict with full server response + + Notes: + Check class docstirng for more info + """ + + return self._processing_response(**kwargs) + + async def aio_captcha_handler(self) -> dict: + """ + Async solving method + + Returns: + Dict with full server response + + Notes: + Check class docstirng for more info + """ + return await self._aio_processing_response() diff --git a/src/python_rucaptcha/tencent.py b/src/python_rucaptcha/tencent.py index 1b92c507..8d3e01f0 100644 --- a/src/python_rucaptcha/tencent.py +++ b/src/python_rucaptcha/tencent.py @@ -74,6 +74,7 @@ def __init__( Notes: https://rucaptcha.com/api-docs/tencent + https://2captcha.com/api-docs/tencent """ super().__init__(method=method, *args, **kwargs)