diff --git a/LICENSE b/LICENSE index 3ce826a2..d3be45e3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Andrei +Copyright (c) 2025 Andrei Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/docs/conf.py b/docs/conf.py index 236d3466..78eaeb31 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,6 +15,7 @@ mt_captcha, re_captcha, atb_captcha, + captcha_fox, capy_puzzle, fun_captcha, key_captcha, diff --git a/docs/index.rst b/docs/index.rst index f53e67f4..9591d647 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -52,6 +52,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 zipp>=3.19.1 # not directly required, pinned by Snyk to avoid a vulnerability diff --git a/pyproject.toml b/pyproject.toml index 39c88696..36297891 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,10 +68,8 @@ keywords = [ "captcha", "amazon_waf", "friendly-captcha" ] -license = {text = "MIT License"} +license = "MIT" classifiers = [ - "License :: OSI Approved :: MIT License", - "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", "Development Status :: 5 - Production/Stable", "Programming Language :: Python", "Programming Language :: Python :: 3", diff --git a/src/python_rucaptcha/__version__.py b/src/python_rucaptcha/__version__.py index 123dd5c0..f0a00b37 100644 --- a/src/python_rucaptcha/__version__.py +++ b/src/python_rucaptcha/__version__.py @@ -1 +1 @@ -__version__ = "6.3.2" +__version__ = "6.4.0" diff --git a/src/python_rucaptcha/captcha_fox.py b/src/python_rucaptcha/captcha_fox.py new file mode 100644 index 00000000..ec4a231a --- /dev/null +++ b/src/python_rucaptcha/captcha_fox.py @@ -0,0 +1,124 @@ +from .core.base import BaseCaptcha +from .core.enums import CaptchaFoxEnm + + +class CaptchaFox(BaseCaptcha): + def __init__( + self, + websiteURL: str, + websiteKey: str, + userAgent: str, + proxyType: str, + proxyAddress: str, + proxyPort: str, + *args, + **kwargs, + ): + """ + The class is used to work with CaptchaFox. + + Args: + rucaptcha_key: User API key + websiteURL: Full URL of the captcha page + websiteKey: The value of the `key` parameter. + It can be found in the page source code or captured in network requests during page loading. + userAgent: User-Agent of your browser will be used to load the captcha. + Use only modern browser's User-Agents + proxyType: Proxy type - `http`, `socks4`, `socks5` + proxyAddress: Proxy IP address or hostname + proxyPort: Proxy port + method: Captcha type + kwargs: Not required params for task creation request + + Examples: + >>> CaptchaFox(rucaptcha_key="aa9011f31111181111168611f1151122", + ... websiteURL="3ceb8624-1970-4e6b-91d5-70317b70b651", + ... websiteKey="sk_xtNxpk6fCdFbxh1_xJeGflSdCE9tn99G", + ... userAgent="Mozilla/5.0 .....", + ... proxyType="socks5", + ... proxyAddress="1.2.3.4", + ... proxyPort="445", + ... ).captcha_handler() + { + "errorId":0, + "status":"ready", + "solution":{ + "token":"142000f.....er" + }, + "cost":"0.002", + "ip":"1.2.3.4", + "createTime":1692863536, + "endTime":1692863556, + "solveCount":0, + "taskId": 73243152973, + } + + >>> await CaptchaFox(rucaptcha_key="aa9011f31111181111168611f1151122", + ... websiteURL="3ceb8624-1970-4e6b-91d5-70317b70b651", + ... websiteKey="sk_xtNxpk6fCdFbxh1_xJeGflSdCE9tn99G", + ... userAgent="Mozilla/5.0 .....", + ... proxyType="socks5", + ... proxyAddress="1.2.3.4", + ... proxyPort="445", + ... ).aio_captcha_handler() + { + "errorId":0, + "status":"ready", + "solution":{ + "token":"142000f.....er" + }, + "cost":"0.002", + "ip":"1.2.3.4", + "createTime":1692863536, + "endTime":1692863556, + "solveCount":0, + "taskId": 73243152973, + } + + Returns: + Dict with full server response + + Notes: + https://2captcha.com/api-docs/captchafox + + https://rucaptcha.com/api-docs/captchafox + """ + super().__init__(method=CaptchaFoxEnm.CaptchaFoxTask, *args, **kwargs) + + self.create_task_payload["task"].update( + { + "websiteURL": websiteURL, + "websiteKey": websiteKey, + "userAgent": userAgent, + "proxyType": proxyType, + "proxyAddress": proxyAddress, + "proxyPort": proxyPort, + } + ) + + 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/core/enums.py b/src/python_rucaptcha/core/enums.py index 9d1aa9a1..ab9a0feb 100644 --- a/src/python_rucaptcha/core/enums.py +++ b/src/python_rucaptcha/core/enums.py @@ -164,3 +164,7 @@ class atbCaptchaEnm(str, MyEnum): class ProsopoEnm(str, MyEnum): ProsopoTask = "ProsopoTask" ProsopoTaskProxyless = "ProsopoTaskProxyless " + + +class CaptchaFoxEnm(str, MyEnum): + CaptchaFoxTask = "CaptchaFoxTask" diff --git a/src/python_rucaptcha/datadome_captcha.py b/src/python_rucaptcha/datadome_captcha.py index 095ee864..90591d8b 100644 --- a/src/python_rucaptcha/datadome_captcha.py +++ b/src/python_rucaptcha/datadome_captcha.py @@ -34,7 +34,7 @@ def __init__( >>> DataDomeCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122", ... websiteURL="3ceb8624-1970-4e6b-91d5-70317b70b651", ... captchaUrl="https://rucaptcha.com/demo/hcaptcha", - ... userAgent="https://rucaptcha.com/demo/hcaptcha", + ... userAgent="Mozilla/5.0 .....", ... proxyType="socks5", ... proxyAddress="1.2.3.4", ... proxyPort="445", @@ -56,7 +56,7 @@ def __init__( >>> await DataDomeCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122", ... websiteURL="3ceb8624-1970-4e6b-91d5-70317b70b651", ... captchaUrl="https://rucaptcha.com/demo/hcaptcha", - ... userAgent="https://rucaptcha.com/demo/hcaptcha", + ... userAgent="Mozilla/5.0 .....", ... proxyType="socks5", ... proxyAddress="1.2.3.4", ... proxyPort="445",