python-rucaptcha 6.6.0__tar.gz → 6.8.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. {python_rucaptcha-6.6.0/src/python_rucaptcha.egg-info → python_rucaptcha-6.8.0}/PKG-INFO +62 -2
  2. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/README.md +61 -1
  3. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/pyproject.toml +3 -0
  4. python_rucaptcha-6.8.0/src/python_rucaptcha/__version__.py +1 -0
  5. python_rucaptcha-6.8.0/src/python_rucaptcha/alibaba_captcha.py +94 -0
  6. python_rucaptcha-6.8.0/src/python_rucaptcha/basilisk_captcha.py +72 -0
  7. python_rucaptcha-6.8.0/src/python_rucaptcha/captchaai.py +160 -0
  8. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/core/base.py +21 -0
  9. python_rucaptcha-6.8.0/src/python_rucaptcha/core/captchaai.py +685 -0
  10. python_rucaptcha-6.8.0/src/python_rucaptcha/core/data/__init__.py +1 -0
  11. python_rucaptcha-6.8.0/src/python_rucaptcha/core/data/captchaai_legacy_profiles.json +19 -0
  12. python_rucaptcha-6.8.0/src/python_rucaptcha/core/data/captchaai_profiles.json +26 -0
  13. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/core/enums.py +20 -0
  14. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/core/serializer.py +7 -3
  15. python_rucaptcha-6.8.0/src/python_rucaptcha/incapsula_captcha.py +75 -0
  16. python_rucaptcha-6.8.0/src/python_rucaptcha/tspd_captcha.py +73 -0
  17. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0/src/python_rucaptcha.egg-info}/PKG-INFO +62 -2
  18. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha.egg-info/SOURCES.txt +14 -0
  19. python_rucaptcha-6.8.0/tests/test_alibaba.py +65 -0
  20. python_rucaptcha-6.8.0/tests/test_basilisk.py +55 -0
  21. python_rucaptcha-6.8.0/tests/test_captchaai.py +379 -0
  22. python_rucaptcha-6.8.0/tests/test_incapsula.py +62 -0
  23. python_rucaptcha-6.8.0/tests/test_tspd.py +60 -0
  24. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_yandex_smart_captcha.py +4 -2
  25. python_rucaptcha-6.6.0/src/python_rucaptcha/__version__.py +0 -1
  26. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/LICENSE +0 -0
  27. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/MANIFEST.in +0 -0
  28. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/setup.cfg +0 -0
  29. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/__init__.py +0 -0
  30. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/altcha_captcha.py +0 -0
  31. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/amazon_waf.py +0 -0
  32. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/atb_captcha.py +0 -0
  33. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/audio_captcha.py +0 -0
  34. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/binance_captcha.py +0 -0
  35. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/bounding_box_captcha.py +0 -0
  36. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/captcha_fox.py +0 -0
  37. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/capy_puzzle.py +0 -0
  38. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/control.py +0 -0
  39. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/coordinates_captcha.py +0 -0
  40. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/core/__init__.py +0 -0
  41. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/core/config.py +0 -0
  42. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/core/result_handler.py +0 -0
  43. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/cutcaptcha.py +0 -0
  44. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/cyber_siara_captcha.py +0 -0
  45. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/datadome_captcha.py +0 -0
  46. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/draw_around_captcha.py +0 -0
  47. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/friendly_captcha.py +0 -0
  48. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/fun_captcha.py +0 -0
  49. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/gee_test.py +0 -0
  50. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/grid_captcha.py +0 -0
  51. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/hcaptcha.py +0 -0
  52. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/image_captcha.py +0 -0
  53. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/key_captcha.py +0 -0
  54. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/lemin_captcha.py +0 -0
  55. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/mt_captcha.py +0 -0
  56. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/prosopo.py +0 -0
  57. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/re_captcha.py +0 -0
  58. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/rotate_captcha.py +0 -0
  59. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/temu_captcha.py +0 -0
  60. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/tencent.py +0 -0
  61. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/text_captcha.py +0 -0
  62. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/turnstile.py +0 -0
  63. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/vk_captcha.py +0 -0
  64. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/yandex_smart_captcha.py +0 -0
  65. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha/yidun_captcha.py +0 -0
  66. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha.egg-info/dependency_links.txt +0 -0
  67. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha.egg-info/requires.txt +0 -0
  68. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/src/python_rucaptcha.egg-info/top_level.txt +0 -0
  69. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_altcha.py +0 -0
  70. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_amazon.py +0 -0
  71. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_audio.py +0 -0
  72. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_binance.py +0 -0
  73. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_bounding_box.py +0 -0
  74. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_capypuzzle.py +0 -0
  75. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_control.py +0 -0
  76. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_coordinates.py +0 -0
  77. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_core.py +0 -0
  78. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_cutcaptcha.py +0 -0
  79. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_cybersiara.py +0 -0
  80. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_datadome.py +0 -0
  81. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_draw_around.py +0 -0
  82. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_friendly_captcha.py +0 -0
  83. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_funcaptcha.py +0 -0
  84. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_geetest.py +0 -0
  85. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_grid.py +0 -0
  86. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_hcaptcha.py +0 -0
  87. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_image.py +0 -0
  88. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_key_captcha.py +0 -0
  89. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_lemin.py +0 -0
  90. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_mtcaptcha.py +0 -0
  91. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_recaptcha.py +0 -0
  92. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_rotate.py +0 -0
  93. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_tencent.py +0 -0
  94. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_text.py +0 -0
  95. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_turnstile.py +0 -0
  96. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_vk_captcha.py +0 -0
  97. {python_rucaptcha-6.6.0 → python_rucaptcha-6.8.0}/tests/test_yidun_captcha.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-rucaptcha
3
- Version: 6.6.0
3
+ Version: 6.8.0
4
4
  Summary: Python 3.9+ RuCaptcha library with AIO module.
5
5
  Author-email: AndreiDrang <python-captcha@pm.me>
6
6
  License-Expression: MIT
@@ -39,7 +39,63 @@ Dynamic: license-file
39
39
  [![Downloads](https://static.pepy.tech/badge/python-rucaptcha/month)](https://pepy.tech/project/python-rucaptcha)
40
40
  [![Documentation](https://img.shields.io/badge/docs-Sphinx-green)](https://andreidrang.github.io/python-rucaptcha/)
41
41
 
42
- **Python 3.9+ library to solve CAPTCHAs automatically using RuCaptcha, 2Captcha, or DeathByCaptcha services.**
42
+ **Python 3.9+ library to solve CAPTCHAs automatically using RuCaptcha, 2Captcha, DeathByCaptcha, or CaptchaAI services.**
43
+
44
+ > **Using CaptchaAI:** compatible high-level classes can pass `service_type=ServiceEnm.CAPTCHAAI`.
45
+ > CaptchaAI uses the classic multipart `in.php`/`res.php` endpoints.
46
+ > ```python
47
+ > from python_rucaptcha.turnstile import Turnstile
48
+ > from python_rucaptcha.core.enums import ServiceEnm
49
+ > result = Turnstile(
50
+ > rucaptcha_key="CAPTCHAAI_KEY",
51
+ > service_type=ServiceEnm.CAPTCHAAI,
52
+ > websiteURL="https://example.com",
53
+ > websiteKey="0x4AAAAAAA...",
54
+ > userAgent="Mozilla/5.0 ...",
55
+ > ).captcha_handler()
56
+ > ```
57
+ >
58
+ > Proxy task types require `proxyType`, `proxyAddress`, and `proxyPort`; credentials are optional:
59
+ > ```python
60
+ > from python_rucaptcha.re_captcha import ReCaptcha
61
+ > from python_rucaptcha.core.enums import ReCaptchaEnm, ServiceEnm
62
+ >
63
+ > result = ReCaptcha(
64
+ > rucaptcha_key="CAPTCHAAI_KEY",
65
+ > service_type=ServiceEnm.CAPTCHAAI,
66
+ > websiteURL="https://example.com/login",
67
+ > websiteKey="SITE_KEY",
68
+ > method=ReCaptchaEnm.RecaptchaV2Task,
69
+ > proxyType="HTTPS",
70
+ > proxyAddress="203.0.113.7",
71
+ > proxyPort=3128,
72
+ > proxyLogin="user",
73
+ > proxyPassword="pass",
74
+ > ).captcha_handler()
75
+ > ```
76
+ >
77
+ > For every documented CaptchaAI method—or a provider method released after this package—use the native,
78
+ > type-free client. `profile` validates a packaged documented contract; omit it to pass provider-native fields
79
+ > through unchanged.
80
+ > ```python
81
+ > from python_rucaptcha.captchaai import CaptchaAI, CaptchaAIFile
82
+ >
83
+ > result = CaptchaAI(
84
+ > rucaptcha_key="CAPTCHAAI_KEY",
85
+ > profile="cloudflare-challenge",
86
+ > params={
87
+ > "pageurl": "https://example.com/protected",
88
+ > "proxy": "user:pass@203.0.113.7:3128",
89
+ > "proxytype": "HTTPS",
90
+ > },
91
+ > ).captcha_handler()
92
+ >
93
+ > image = CaptchaAI(
94
+ > rucaptcha_key="CAPTCHAAI_KEY",
95
+ > profile="normal-solve-file",
96
+ > files={"file": CaptchaAIFile(b"... PNG bytes ...", "captcha.png", "image/png")},
97
+ > ).captcha_handler()
98
+ > ```
43
99
 
44
100
  ## What is this?
45
101
 
@@ -142,6 +198,10 @@ token = asyncio.run(solve())
142
198
  | KeyCaptcha | `KeyCaptcha` | KeyCAPTCHA service |
143
199
  | Amazon WAF | `AmazonWaf` | AWS WAF challenge |
144
200
  | ALTCHA | `AltchaCaptcha` | ALTCHA challenge |
201
+ | TSPD | `TSPDCaptcha` | Cookie-based TSPD protection |
202
+ | Basilisk | `BasiliskCaptcha` | Token-based Basilisk challenge |
203
+ | Alibaba | `AlibabaCaptcha` | Token-based Alibaba challenge |
204
+ | Imperva/Incapsula | `IncapsulaCaptcha` | Cookie-based Imperva protection |
145
205
  | Binance | `BinanceCaptcha` | Token-based Binance challenge |
146
206
  | Grid | `GridCaptcha` | Select grid cells |
147
207
  | Coordinates | `CoordinatesCaptcha` | Click on coordinates |
@@ -5,7 +5,63 @@
5
5
  [![Downloads](https://static.pepy.tech/badge/python-rucaptcha/month)](https://pepy.tech/project/python-rucaptcha)
6
6
  [![Documentation](https://img.shields.io/badge/docs-Sphinx-green)](https://andreidrang.github.io/python-rucaptcha/)
7
7
 
8
- **Python 3.9+ library to solve CAPTCHAs automatically using RuCaptcha, 2Captcha, or DeathByCaptcha services.**
8
+ **Python 3.9+ library to solve CAPTCHAs automatically using RuCaptcha, 2Captcha, DeathByCaptcha, or CaptchaAI services.**
9
+
10
+ > **Using CaptchaAI:** compatible high-level classes can pass `service_type=ServiceEnm.CAPTCHAAI`.
11
+ > CaptchaAI uses the classic multipart `in.php`/`res.php` endpoints.
12
+ > ```python
13
+ > from python_rucaptcha.turnstile import Turnstile
14
+ > from python_rucaptcha.core.enums import ServiceEnm
15
+ > result = Turnstile(
16
+ > rucaptcha_key="CAPTCHAAI_KEY",
17
+ > service_type=ServiceEnm.CAPTCHAAI,
18
+ > websiteURL="https://example.com",
19
+ > websiteKey="0x4AAAAAAA...",
20
+ > userAgent="Mozilla/5.0 ...",
21
+ > ).captcha_handler()
22
+ > ```
23
+ >
24
+ > Proxy task types require `proxyType`, `proxyAddress`, and `proxyPort`; credentials are optional:
25
+ > ```python
26
+ > from python_rucaptcha.re_captcha import ReCaptcha
27
+ > from python_rucaptcha.core.enums import ReCaptchaEnm, ServiceEnm
28
+ >
29
+ > result = ReCaptcha(
30
+ > rucaptcha_key="CAPTCHAAI_KEY",
31
+ > service_type=ServiceEnm.CAPTCHAAI,
32
+ > websiteURL="https://example.com/login",
33
+ > websiteKey="SITE_KEY",
34
+ > method=ReCaptchaEnm.RecaptchaV2Task,
35
+ > proxyType="HTTPS",
36
+ > proxyAddress="203.0.113.7",
37
+ > proxyPort=3128,
38
+ > proxyLogin="user",
39
+ > proxyPassword="pass",
40
+ > ).captcha_handler()
41
+ > ```
42
+ >
43
+ > For every documented CaptchaAI method—or a provider method released after this package—use the native,
44
+ > type-free client. `profile` validates a packaged documented contract; omit it to pass provider-native fields
45
+ > through unchanged.
46
+ > ```python
47
+ > from python_rucaptcha.captchaai import CaptchaAI, CaptchaAIFile
48
+ >
49
+ > result = CaptchaAI(
50
+ > rucaptcha_key="CAPTCHAAI_KEY",
51
+ > profile="cloudflare-challenge",
52
+ > params={
53
+ > "pageurl": "https://example.com/protected",
54
+ > "proxy": "user:pass@203.0.113.7:3128",
55
+ > "proxytype": "HTTPS",
56
+ > },
57
+ > ).captcha_handler()
58
+ >
59
+ > image = CaptchaAI(
60
+ > rucaptcha_key="CAPTCHAAI_KEY",
61
+ > profile="normal-solve-file",
62
+ > files={"file": CaptchaAIFile(b"... PNG bytes ...", "captcha.png", "image/png")},
63
+ > ).captcha_handler()
64
+ > ```
9
65
 
10
66
  ## What is this?
11
67
 
@@ -108,6 +164,10 @@ token = asyncio.run(solve())
108
164
  | KeyCaptcha | `KeyCaptcha` | KeyCAPTCHA service |
109
165
  | Amazon WAF | `AmazonWaf` | AWS WAF challenge |
110
166
  | ALTCHA | `AltchaCaptcha` | ALTCHA challenge |
167
+ | TSPD | `TSPDCaptcha` | Cookie-based TSPD protection |
168
+ | Basilisk | `BasiliskCaptcha` | Token-based Basilisk challenge |
169
+ | Alibaba | `AlibabaCaptcha` | Token-based Alibaba challenge |
170
+ | Imperva/Incapsula | `IncapsulaCaptcha` | Cookie-based Imperva protection |
111
171
  | Binance | `BinanceCaptcha` | Token-based Binance challenge |
112
172
  | Grid | `GridCaptcha` | Select grid cells |
113
173
  | Coordinates | `CoordinatesCaptcha` | Click on coordinates |
@@ -99,6 +99,9 @@ dependencies = [
99
99
  where = ["src"]
100
100
  include = ["python_rucaptcha*"]
101
101
 
102
+ [tool.setuptools.package-data]
103
+ python_rucaptcha = ["core/data/*.json"]
104
+
102
105
  [tool.setuptools.dynamic]
103
106
  version = {attr = "python_rucaptcha.__version__"}
104
107
 
@@ -0,0 +1 @@
1
+ __version__ = "6.8.0"
@@ -0,0 +1,94 @@
1
+ from typing import Union, Optional
2
+
3
+ from .core.base import BaseCaptcha
4
+ from .core.enums import AlibabaEnm
5
+
6
+
7
+ class AlibabaCaptcha(BaseCaptcha):
8
+ """Solve Alibaba captcha with a proxyless or customer-provided proxy task."""
9
+
10
+ def __init__(
11
+ self,
12
+ websiteURL: str,
13
+ sceneId: str,
14
+ prefix: str,
15
+ method: Union[str, AlibabaEnm] = AlibabaEnm.AlibabaTaskProxyless,
16
+ userId: Optional[str] = None,
17
+ userUserId: Optional[str] = None,
18
+ verifyType: Optional[str] = None,
19
+ region: Optional[str] = None,
20
+ userCertifyId: Optional[str] = None,
21
+ apiGetLib: Optional[str] = None,
22
+ userAgent: Optional[str] = None,
23
+ proxyType: Optional[str] = None,
24
+ proxyAddress: Optional[str] = None,
25
+ proxyPort: Optional[int] = None,
26
+ proxyLogin: Optional[str] = None,
27
+ proxyPassword: Optional[str] = None,
28
+ *args,
29
+ **kwargs,
30
+ ):
31
+ """
32
+ Args:
33
+ rucaptcha_key: User API key.
34
+ websiteURL: Full URL of the page where Alibaba captcha is loaded.
35
+ sceneId: Captcha scenario identifier.
36
+ prefix: Captcha initialization prefix from the loading request.
37
+ method: ``AlibabaTaskProxyless`` or ``AlibabaTask``.
38
+ userId: Optional website-side user or session identifier.
39
+ userUserId: Optional secondary user identifier.
40
+ verifyType: Optional verification mechanism type.
41
+ region: Optional Alibaba processing region.
42
+ userCertifyId: Optional verification identifier.
43
+ apiGetLib: Optional URL of the captcha JavaScript library.
44
+ userAgent: Optional browser User-Agent.
45
+ proxyType: Proxy type for ``AlibabaTask``.
46
+ proxyAddress: Proxy IP address or hostname.
47
+ proxyPort: Proxy port.
48
+ proxyLogin: Optional proxy login.
49
+ proxyPassword: Optional proxy password.
50
+ kwargs: Additional task parameters.
51
+ """
52
+ super().__init__(method=method, *args, **kwargs)
53
+
54
+ if method not in AlibabaEnm.list_values():
55
+ raise ValueError(f"Invalid method parameter set, available - {AlibabaEnm.list_values()}")
56
+
57
+ task_data = {"websiteURL": websiteURL, "sceneId": sceneId, "prefix": prefix}
58
+ optional_data = {
59
+ "userId": userId,
60
+ "userUserId": userUserId,
61
+ "verifyType": verifyType,
62
+ "region": region,
63
+ "userCertifyId": userCertifyId,
64
+ "apiGetLib": apiGetLib,
65
+ "userAgent": userAgent,
66
+ }
67
+ task_data.update({key: value for key, value in optional_data.items() if value is not None})
68
+
69
+ if method == AlibabaEnm.AlibabaTask.value:
70
+ if not all([proxyType, proxyAddress, proxyPort]):
71
+ raise ValueError(
72
+ "Proxy parameters (proxyType, proxyAddress, proxyPort) are required for AlibabaTask"
73
+ )
74
+ task_data.update(
75
+ {
76
+ "proxyType": proxyType,
77
+ "proxyAddress": proxyAddress,
78
+ "proxyPort": proxyPort,
79
+ }
80
+ )
81
+ if proxyLogin is not None:
82
+ task_data["proxyLogin"] = proxyLogin
83
+ if proxyPassword is not None:
84
+ task_data["proxyPassword"] = proxyPassword
85
+
86
+ self.create_task_payload["task"].update(task_data)
87
+
88
+ def captcha_handler(self, **kwargs) -> dict:
89
+ """Synchronously submit and poll the Alibaba task."""
90
+ return self._processing_response(**kwargs)
91
+
92
+ async def aio_captcha_handler(self) -> dict:
93
+ """Asynchronously submit and poll the Alibaba task."""
94
+ return await self._aio_processing_response()
@@ -0,0 +1,72 @@
1
+ from typing import Union, Optional
2
+
3
+ from .core.base import BaseCaptcha
4
+ from .core.enums import BasiliskEnm
5
+
6
+
7
+ class BasiliskCaptcha(BaseCaptcha):
8
+ """Solve Basilisk captcha with a proxyless or customer-provided proxy task."""
9
+
10
+ def __init__(
11
+ self,
12
+ websiteURL: str,
13
+ websiteKey: str,
14
+ method: Union[str, BasiliskEnm] = BasiliskEnm.BasiliskTaskProxyless,
15
+ userAgent: Optional[str] = None,
16
+ proxyType: Optional[str] = None,
17
+ proxyAddress: Optional[str] = None,
18
+ proxyPort: Optional[int] = None,
19
+ proxyLogin: Optional[str] = None,
20
+ proxyPassword: Optional[str] = None,
21
+ *args,
22
+ **kwargs,
23
+ ):
24
+ """
25
+ Args:
26
+ rucaptcha_key: User API key.
27
+ websiteURL: Full URL of the page where Basilisk is loaded.
28
+ websiteKey: The page's Basilisk data-sitekey value.
29
+ method: ``BasiliskTaskProxyless`` or ``BasiliskTask``.
30
+ userAgent: Optional browser User-Agent.
31
+ proxyType: Proxy type for ``BasiliskTask``.
32
+ proxyAddress: Proxy IP address or hostname.
33
+ proxyPort: Proxy port.
34
+ proxyLogin: Optional proxy login.
35
+ proxyPassword: Optional proxy password.
36
+ kwargs: Additional task parameters.
37
+ """
38
+ super().__init__(method=method, *args, **kwargs)
39
+
40
+ if method not in BasiliskEnm.list_values():
41
+ raise ValueError(f"Invalid method parameter set, available - {BasiliskEnm.list_values()}")
42
+
43
+ task_data = {"websiteURL": websiteURL, "websiteKey": websiteKey}
44
+ if userAgent is not None:
45
+ task_data["userAgent"] = userAgent
46
+
47
+ if method == BasiliskEnm.BasiliskTask.value:
48
+ if not all([proxyType, proxyAddress, proxyPort]):
49
+ raise ValueError(
50
+ "Proxy parameters (proxyType, proxyAddress, proxyPort) are required for BasiliskTask"
51
+ )
52
+ task_data.update(
53
+ {
54
+ "proxyType": proxyType,
55
+ "proxyAddress": proxyAddress,
56
+ "proxyPort": proxyPort,
57
+ }
58
+ )
59
+ if proxyLogin is not None:
60
+ task_data["proxyLogin"] = proxyLogin
61
+ if proxyPassword is not None:
62
+ task_data["proxyPassword"] = proxyPassword
63
+
64
+ self.create_task_payload["task"].update(task_data)
65
+
66
+ def captcha_handler(self, **kwargs) -> dict:
67
+ """Synchronously submit and poll the Basilisk task."""
68
+ return self._processing_response(**kwargs)
69
+
70
+ async def aio_captcha_handler(self) -> dict:
71
+ """Asynchronously submit and poll the Basilisk task."""
72
+ return await self._aio_processing_response()
@@ -0,0 +1,160 @@
1
+ """Native, future-compatible CaptchaAI classic API client."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Mapping
6
+
7
+ import requests
8
+ from requests.adapters import HTTPAdapter
9
+
10
+ from .core import captchaai as transport
11
+ from .core.enums import ServiceEnm
12
+ from .core.config import RETRIES
13
+ from .core.serializer import CaptchaOptionsSer
14
+
15
+ CaptchaAIFile = transport.CaptchaAIFile
16
+
17
+
18
+ class CaptchaAI:
19
+ """Client for CaptchaAI's classic multipart API.
20
+
21
+ A packaged profile can validate a documented method contract. Omitting the
22
+ profile allows provider-native parameters for methods not yet represented
23
+ in the package metadata.
24
+
25
+ Attributes:
26
+ key: CaptchaAI API key used for requests.
27
+ method: Provider method submitted by the client.
28
+ params: Provider-native scalar parameters.
29
+ files: Multipart file parts keyed by provider field name.
30
+ profile: Optional packaged profile name.
31
+ poll: Whether to poll for a result after submission.
32
+ """
33
+
34
+ def __init__(
35
+ self,
36
+ rucaptcha_key: str,
37
+ method: str | None = None,
38
+ params: Mapping[str, Any] | None = None,
39
+ *,
40
+ files: Mapping[str, CaptchaAIFile] | None = None,
41
+ profile: str | None = None,
42
+ poll: bool | None = None,
43
+ sleep_time: int = 10,
44
+ ):
45
+ """Create a client for one CaptchaAI method.
46
+
47
+ Args:
48
+ rucaptcha_key: API key used for CaptchaAI requests.
49
+ method: Provider-native method name. Required unless ``profile``
50
+ supplies the method.
51
+ params: Provider-native scalar parameters.
52
+ files: Multipart file parts keyed by provider field name.
53
+ profile: Optional packaged profile used for validation and defaults.
54
+ poll: Whether to poll after submission. If omitted, the profile
55
+ determines the default and native methods poll by default.
56
+ sleep_time: Seconds between result polls.
57
+
58
+ Raises:
59
+ ValueError: If neither ``method`` nor ``profile`` is supplied.
60
+ """
61
+ if method is None:
62
+ if profile is None:
63
+ raise ValueError("CaptchaAI requires a method or a documented profile")
64
+ method = transport.profile_method(profile)
65
+
66
+ self.key = rucaptcha_key
67
+ self.method = method
68
+ self.params = dict(params or {})
69
+ self.files = dict(files or {})
70
+ self.profile = profile
71
+ self.poll = poll
72
+ self.options = CaptchaOptionsSer(sleep_time=sleep_time, service_type=ServiceEnm.CAPTCHAAI)
73
+ self.options.urls_set()
74
+ self.session = requests.Session()
75
+ self.session.mount("http://", HTTPAdapter(max_retries=RETRIES))
76
+ self.session.mount("https://", HTTPAdapter(max_retries=RETRIES))
77
+
78
+ @classmethod
79
+ def profiles(cls) -> tuple[str, ...]:
80
+ """List the packaged CaptchaAI profile names.
81
+
82
+ Returns:
83
+ Profile names available for declarative validation.
84
+ """
85
+ return transport.profiles()
86
+
87
+ def captcha_handler(self) -> dict[str, Any]:
88
+ """Submit the configured method and optionally poll for its result.
89
+
90
+ Returns:
91
+ A normalized result mapping containing either the solution or an
92
+ error description.
93
+ """
94
+ return transport.solve_native(
95
+ key=self.key,
96
+ method=self.method,
97
+ params=self.params,
98
+ files=self.files,
99
+ profile=self.profile,
100
+ poll=self.poll,
101
+ url_request=self.options.url_request,
102
+ url_response=self.options.url_response,
103
+ sleep_time=self.options.sleep_time,
104
+ session=self.session,
105
+ )
106
+
107
+ async def aio_captcha_handler(self) -> dict[str, Any]:
108
+ """Asynchronously submit the method and optionally poll for its result.
109
+
110
+ Returns:
111
+ A normalized result mapping containing either the solution or an
112
+ error description.
113
+ """
114
+ return await transport.aio_solve_native(
115
+ key=self.key,
116
+ method=self.method,
117
+ params=self.params,
118
+ files=self.files,
119
+ profile=self.profile,
120
+ poll=self.poll,
121
+ url_request=self.options.url_request,
122
+ url_response=self.options.url_response,
123
+ sleep_time=self.options.sleep_time,
124
+ )
125
+
126
+ def get_balance(self) -> dict[str, Any]:
127
+ """Fetch the account balance through the CaptchaAI control API.
128
+
129
+ Returns:
130
+ The provider response with the balance value when successful, or
131
+ the normalized error mapping returned by the transport.
132
+ """
133
+ return transport.control(self.key, "balance", self.options.url_response, session=self.session)
134
+
135
+ async def aio_get_balance(self) -> dict[str, Any]:
136
+ """Asynchronously fetch the account balance.
137
+
138
+ Returns:
139
+ The provider response with the balance value when successful, or
140
+ the normalized error mapping returned by the transport.
141
+ """
142
+ return await transport.aio_control(self.key, "balance", self.options.url_response)
143
+
144
+ def get_threads_info(self) -> dict[str, Any]:
145
+ """Fetch total and active thread information.
146
+
147
+ Returns:
148
+ The provider response with thread information, or the normalized
149
+ error mapping returned by the transport.
150
+ """
151
+ return transport.control(self.key, "threads_info", self.options.url_response, session=self.session)
152
+
153
+ async def aio_get_threads_info(self) -> dict[str, Any]:
154
+ """Asynchronously fetch total and active thread information.
155
+
156
+ Returns:
157
+ The provider response with thread information, or the normalized
158
+ error mapping returned by the transport.
159
+ """
160
+ return await transport.aio_control(self.key, "threads_info", self.options.url_response)
@@ -82,6 +82,17 @@ class BaseCaptcha:
82
82
  Method processing captcha solving task creation result
83
83
  :param kwargs: additional params for Requests library
84
84
  """
85
+ # CaptchaAI speaks the classic in.php/res.php API, not the JSON createTask API.
86
+ if self.params.service_type == ServiceEnm.CAPTCHAAI.value:
87
+ from . import captchaai
88
+
89
+ return captchaai.solve(
90
+ create_task_payload=self.create_task_payload,
91
+ url_request=self.params.url_request,
92
+ url_response=self.params.url_response,
93
+ sleep_time=self.params.sleep_time,
94
+ session=self.session,
95
+ )
85
96
  try:
86
97
  response = GetTaskResultResponseSer(
87
98
  **self.session.post(self.params.url_request, json=self.create_task_payload, **kwargs).json()
@@ -126,6 +137,16 @@ class BaseCaptcha:
126
137
  """
127
138
  Method processing async captcha solving task creation result
128
139
  """
140
+ # CaptchaAI speaks the classic in.php/res.php API, not the JSON createTask API.
141
+ if self.params.service_type == ServiceEnm.CAPTCHAAI.value:
142
+ from . import captchaai
143
+
144
+ return await captchaai.aio_solve(
145
+ create_task_payload=self.create_task_payload,
146
+ url_request=self.params.url_request,
147
+ url_response=self.params.url_response,
148
+ sleep_time=self.params.sleep_time,
149
+ )
129
150
  try:
130
151
  # make async or sync request
131
152
  response = await self.__aio_create_task()