python-rucaptcha 6.5.0__tar.gz → 6.7.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 (93) hide show
  1. python_rucaptcha-6.7.0/PKG-INFO +250 -0
  2. python_rucaptcha-6.7.0/README.md +216 -0
  3. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/pyproject.toml +6 -2
  4. python_rucaptcha-6.7.0/src/python_rucaptcha/__version__.py +1 -0
  5. python_rucaptcha-6.7.0/src/python_rucaptcha/altcha_captcha.py +152 -0
  6. python_rucaptcha-6.7.0/src/python_rucaptcha/binance_captcha.py +155 -0
  7. python_rucaptcha-6.7.0/src/python_rucaptcha/captchaai.py +160 -0
  8. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/core/base.py +21 -0
  9. python_rucaptcha-6.7.0/src/python_rucaptcha/core/captchaai.py +685 -0
  10. python_rucaptcha-6.7.0/src/python_rucaptcha/core/data/__init__.py +1 -0
  11. python_rucaptcha-6.7.0/src/python_rucaptcha/core/data/captchaai_legacy_profiles.json +19 -0
  12. python_rucaptcha-6.7.0/src/python_rucaptcha/core/data/captchaai_profiles.json +26 -0
  13. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/core/enums.py +23 -0
  14. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/core/result_handler.py +0 -1
  15. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/core/serializer.py +7 -3
  16. python_rucaptcha-6.7.0/src/python_rucaptcha/vk_captcha.py +225 -0
  17. python_rucaptcha-6.7.0/src/python_rucaptcha/yandex_smart_captcha.py +246 -0
  18. python_rucaptcha-6.7.0/src/python_rucaptcha/yidun_captcha.py +171 -0
  19. python_rucaptcha-6.7.0/src/python_rucaptcha.egg-info/PKG-INFO +250 -0
  20. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha.egg-info/SOURCES.txt +16 -1
  21. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha.egg-info/requires.txt +1 -1
  22. python_rucaptcha-6.7.0/tests/test_altcha.py +185 -0
  23. python_rucaptcha-6.7.0/tests/test_binance.py +197 -0
  24. python_rucaptcha-6.7.0/tests/test_captchaai.py +379 -0
  25. python_rucaptcha-6.7.0/tests/test_vk_captcha.py +175 -0
  26. python_rucaptcha-6.7.0/tests/test_yandex_smart_captcha.py +236 -0
  27. python_rucaptcha-6.7.0/tests/test_yidun_captcha.py +192 -0
  28. python_rucaptcha-6.5.0/PKG-INFO +0 -108
  29. python_rucaptcha-6.5.0/README.md +0 -74
  30. python_rucaptcha-6.5.0/src/python_rucaptcha/__version__.py +0 -1
  31. python_rucaptcha-6.5.0/src/python_rucaptcha/vk_captcha.py +0 -120
  32. python_rucaptcha-6.5.0/src/python_rucaptcha.egg-info/PKG-INFO +0 -108
  33. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/LICENSE +0 -0
  34. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/MANIFEST.in +0 -0
  35. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/setup.cfg +0 -0
  36. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/__init__.py +0 -0
  37. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/amazon_waf.py +0 -0
  38. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/atb_captcha.py +0 -0
  39. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/audio_captcha.py +0 -0
  40. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/bounding_box_captcha.py +0 -0
  41. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/captcha_fox.py +0 -0
  42. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/capy_puzzle.py +0 -0
  43. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/control.py +0 -0
  44. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/coordinates_captcha.py +0 -0
  45. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/core/__init__.py +0 -0
  46. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/core/config.py +0 -0
  47. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/cutcaptcha.py +0 -0
  48. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/cyber_siara_captcha.py +0 -0
  49. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/datadome_captcha.py +0 -0
  50. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/draw_around_captcha.py +0 -0
  51. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/friendly_captcha.py +0 -0
  52. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/fun_captcha.py +0 -0
  53. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/gee_test.py +0 -0
  54. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/grid_captcha.py +0 -0
  55. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/hcaptcha.py +0 -0
  56. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/image_captcha.py +0 -0
  57. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/key_captcha.py +0 -0
  58. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/lemin_captcha.py +0 -0
  59. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/mt_captcha.py +0 -0
  60. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/prosopo.py +0 -0
  61. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/re_captcha.py +0 -0
  62. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/rotate_captcha.py +0 -0
  63. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/temu_captcha.py +0 -0
  64. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/tencent.py +0 -0
  65. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/text_captcha.py +0 -0
  66. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha/turnstile.py +0 -0
  67. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha.egg-info/dependency_links.txt +0 -0
  68. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/src/python_rucaptcha.egg-info/top_level.txt +0 -0
  69. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_amazon.py +0 -0
  70. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_audio.py +0 -0
  71. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_bounding_box.py +0 -0
  72. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_capypuzzle.py +0 -0
  73. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_control.py +0 -0
  74. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_coordinates.py +0 -0
  75. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_core.py +0 -0
  76. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_cutcaptcha.py +0 -0
  77. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_cybersiara.py +0 -0
  78. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_datadome.py +0 -0
  79. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_draw_around.py +0 -0
  80. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_friendly_captcha.py +0 -0
  81. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_funcaptcha.py +0 -0
  82. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_geetest.py +0 -0
  83. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_grid.py +0 -0
  84. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_hcaptcha.py +0 -0
  85. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_image.py +0 -0
  86. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_key_captcha.py +0 -0
  87. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_lemin.py +0 -0
  88. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_mtcaptcha.py +0 -0
  89. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_recaptcha.py +0 -0
  90. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_rotate.py +0 -0
  91. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_tencent.py +0 -0
  92. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_text.py +0 -0
  93. {python_rucaptcha-6.5.0 → python_rucaptcha-6.7.0}/tests/test_turnstile.py +0 -0
@@ -0,0 +1,250 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-rucaptcha
3
+ Version: 6.7.0
4
+ Summary: Python 3.9+ RuCaptcha library with AIO module.
5
+ Author-email: AndreiDrang <python-captcha@pm.me>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://andreidrang.github.io/python-rucaptcha/
8
+ Project-URL: Documentation, https://andreidrang.github.io/python-rucaptcha/
9
+ Project-URL: Repository, https://github.com/AndreiDrang/python-rucaptcha
10
+ Project-URL: Issues, https://github.com/AndreiDrang/python-rucaptcha/issues
11
+ Project-URL: Changelog, https://github.com/AndreiDrang/python-rucaptcha/releases
12
+ Keywords: captcha,rucaptcha,2captcha,deathbycaptcha,recaptcha,geetest,hcaptcha,capypuzzle,rotatecaptcha,funcaptcha,keycaptcha,python3,recaptcha,captcha,security,tencent,atb_captcha,python-library,python-rucaptcha,rucaptcha-client,yandex,turnstile,amazon,amazon_waf,vk-captcha,fox-captcha,temu-captcha,friendly-captcha,binance-captcha
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Framework :: AsyncIO
23
+ Classifier: Operating System :: Unix
24
+ Classifier: Operating System :: Microsoft :: Windows
25
+ Classifier: Operating System :: MacOS
26
+ Requires-Python: >=3.9
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: requests>=2.21.0
30
+ Requires-Dist: aiohttp>=3.9.2
31
+ Requires-Dist: msgspec<0.21,>=0.18
32
+ Requires-Dist: tenacity<10,>=8
33
+ Dynamic: license-file
34
+
35
+ # python-rucaptcha
36
+
37
+ [![PyPI version](https://badge.fury.io/py/python-rucaptcha.svg)](https://badge.fury.io/py/python-rucaptcha)
38
+ [![Python versions](https://img.shields.io/pypi/pyversions/python-rucaptcha.svg?logo=python&logoColor=FBE072)](https://badge.fury.io/py/python-rucaptcha)
39
+ [![Downloads](https://static.pepy.tech/badge/python-rucaptcha/month)](https://pepy.tech/project/python-rucaptcha)
40
+ [![Documentation](https://img.shields.io/badge/docs-Sphinx-green)](https://andreidrang.github.io/python-rucaptcha/)
41
+
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
+ > ```
99
+
100
+ ## What is this?
101
+
102
+ This library automates CAPTCHA solving by connecting to third-party services. When your code encounters a CAPTCHA, python-rucaptcha sends it to the service, waits for a human to solve it, and returns the solution to your application.
103
+
104
+ **Supports 30+ CAPTCHA types:**
105
+ - reCAPTCHA v2/v3, hCaptcha, Cloudflare Turnstile
106
+ - Image captchas, Audio captchas
107
+ - GeeTest, KeyCaptcha, Amazon WAF, Tencent
108
+ - And many more...
109
+
110
+ ## Quick Start
111
+
112
+ ### 1. Install
113
+
114
+ ```bash
115
+ pip install python-rucaptcha
116
+ ```
117
+
118
+ ### 2. Get an API Key
119
+
120
+ Sign up at [RuCaptcha](https://rucaptcha.com) or [2Captcha](https://2captcha.com), then copy your API key from the dashboard.
121
+
122
+ ### 3. Solve a CAPTCHA
123
+
124
+ ```python
125
+ from python_rucaptcha import HCaptcha
126
+
127
+ # Your API key
128
+ key = "your_api_key_here"
129
+
130
+ # Solve hCaptcha
131
+ result = HCaptcha(aptcha_key=key).captcha_handler(site_url="https://example.com", site_key="abc123")
132
+
133
+ if result['code'] == 0:
134
+ print(f"Solved! Token: {result['token']}")
135
+ else:
136
+ print(f"Error: {result['message']}")
137
+ ```
138
+
139
+ ### Solving Different CAPTCHA Types
140
+
141
+ **reCAPTCHA v2:**
142
+ ```python
143
+ from python_rucaptcha import ReCaptcha
144
+
145
+ result = ReCaptcha(api_key).captcha_handler(
146
+ site_url="https://example.com",
147
+ site_key="your_site_key"
148
+ )
149
+ ```
150
+
151
+ **Image CAPTCHA:**
152
+ ```python
153
+ from python_rucaptcha import ImageCaptcha
154
+
155
+ result = ImageCaptcha(api_key).captcha_handler(
156
+ image_link="https://example.com/captcha.jpg"
157
+ )
158
+ ```
159
+
160
+ **ALTCHA:**
161
+ ```python
162
+ from python_rucaptcha import AltchaCaptcha
163
+ from python_rucaptcha.core.enums import AltchaEnm
164
+
165
+ result = AltchaCaptcha(
166
+ rucaptcha_key=api_key,
167
+ websiteURL="https://example.com",
168
+ challengeURL="https://example.com/altcha/challenge",
169
+ method=AltchaEnm.AltchaTaskProxyless,
170
+ ).captcha_handler()
171
+ ```
172
+
173
+ **Using async:**
174
+ ```python
175
+ import asyncio
176
+ from python_rucaptcha import HCaptcha
177
+
178
+ async def solve():
179
+ result = await HCaptcha(api_key).aio_captcha_handler(
180
+ site_url="https://example.com",
181
+ site_key="abc123"
182
+ )
183
+ return result
184
+
185
+ token = asyncio.run(solve())
186
+ ```
187
+
188
+ ## Supported CAPTCHA Types
189
+
190
+ | CAPTCHA | Module | Description |
191
+ |---------|--------|-------------|
192
+ | reCAPTCHA v2/v3 | `ReCaptcha` | Google reCAPTCHA |
193
+ | hCaptcha | `HCaptcha` | hCaptcha challenge |
194
+ | Cloudflare Turnstile | `Turnstile` | Cloudflare protection |
195
+ | Image | `ImageCaptcha` | Type the text from image |
196
+ | Audio | `AudioCaptcha` | Listen and type audio |
197
+ | GeeTest | `GeeTest` | Chinese geetest puzzles |
198
+ | KeyCaptcha | `KeyCaptcha` | KeyCAPTCHA service |
199
+ | Amazon WAF | `AmazonWaf` | AWS WAF challenge |
200
+ | ALTCHA | `AltchaCaptcha` | ALTCHA challenge |
201
+ | Binance | `BinanceCaptcha` | Token-based Binance challenge |
202
+ | Grid | `GridCaptcha` | Select grid cells |
203
+ | Coordinates | `CoordinatesCaptcha` | Click on coordinates |
204
+ | And 20+ more | ... | See [full docs](https://andreidrang.github.io/python-rucaptcha/) |
205
+
206
+ ## Switching Services
207
+
208
+ Use the same code with different services:
209
+
210
+ ```python
211
+ from python_rucaptcha import HCaptcha
212
+ from python_rucaptcha.core.enums import ServiceEnm
213
+
214
+ # Use 2Captcha (default)
215
+ result = HCaptcha("2captcha_key").captcha_handler(...)
216
+
217
+ # Use RuCaptcha
218
+ result = HCaptcha("rucaptcha_key", service_type=ServiceEnm.RuCaptcha).captcha_handler(...)
219
+
220
+ # Use DeathByCaptcha
221
+ result = HCaptcha("dbc_user:dbc_pass", service_type=ServiceEnm.DeathByCaptcha).captcha_handler(...)
222
+ ```
223
+
224
+ ## Testing
225
+
226
+ ```bash
227
+ # Set your API key
228
+ export RUCAPTCHA_KEY="your_key_here"
229
+
230
+ # Run tests
231
+ make tests
232
+ ```
233
+
234
+ ## Documentation
235
+
236
+ For advanced usage, configuration options, and all CAPTCHA types, see the [full documentation](https://andreidrang.github.io/python-rucaptcha/).
237
+
238
+ ## Support
239
+
240
+ - **Telegram:** [pythoncaptcha](https://t.me/pythoncaptcha)
241
+ - **Email:** python-captcha@pm.me
242
+ - **Issues:** [GitHub Issues](https://github.com/AndreiDrang/python-rucaptcha/issues)
243
+
244
+ ## Changelog
245
+
246
+ See [Releases](https://github.com/AndreiDrang/python-rucaptcha/releases) for full changelog.
247
+
248
+ - **v6.0** - Refactored to use msgspec (faster), API v2, dropped Python 3.8
249
+ - **v5.3** - Added DeathByCaptcha support
250
+ - **v5.2** - Added audio CAPTCHA solving
@@ -0,0 +1,216 @@
1
+ # python-rucaptcha
2
+
3
+ [![PyPI version](https://badge.fury.io/py/python-rucaptcha.svg)](https://badge.fury.io/py/python-rucaptcha)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/python-rucaptcha.svg?logo=python&logoColor=FBE072)](https://badge.fury.io/py/python-rucaptcha)
5
+ [![Downloads](https://static.pepy.tech/badge/python-rucaptcha/month)](https://pepy.tech/project/python-rucaptcha)
6
+ [![Documentation](https://img.shields.io/badge/docs-Sphinx-green)](https://andreidrang.github.io/python-rucaptcha/)
7
+
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
+ > ```
65
+
66
+ ## What is this?
67
+
68
+ This library automates CAPTCHA solving by connecting to third-party services. When your code encounters a CAPTCHA, python-rucaptcha sends it to the service, waits for a human to solve it, and returns the solution to your application.
69
+
70
+ **Supports 30+ CAPTCHA types:**
71
+ - reCAPTCHA v2/v3, hCaptcha, Cloudflare Turnstile
72
+ - Image captchas, Audio captchas
73
+ - GeeTest, KeyCaptcha, Amazon WAF, Tencent
74
+ - And many more...
75
+
76
+ ## Quick Start
77
+
78
+ ### 1. Install
79
+
80
+ ```bash
81
+ pip install python-rucaptcha
82
+ ```
83
+
84
+ ### 2. Get an API Key
85
+
86
+ Sign up at [RuCaptcha](https://rucaptcha.com) or [2Captcha](https://2captcha.com), then copy your API key from the dashboard.
87
+
88
+ ### 3. Solve a CAPTCHA
89
+
90
+ ```python
91
+ from python_rucaptcha import HCaptcha
92
+
93
+ # Your API key
94
+ key = "your_api_key_here"
95
+
96
+ # Solve hCaptcha
97
+ result = HCaptcha(aptcha_key=key).captcha_handler(site_url="https://example.com", site_key="abc123")
98
+
99
+ if result['code'] == 0:
100
+ print(f"Solved! Token: {result['token']}")
101
+ else:
102
+ print(f"Error: {result['message']}")
103
+ ```
104
+
105
+ ### Solving Different CAPTCHA Types
106
+
107
+ **reCAPTCHA v2:**
108
+ ```python
109
+ from python_rucaptcha import ReCaptcha
110
+
111
+ result = ReCaptcha(api_key).captcha_handler(
112
+ site_url="https://example.com",
113
+ site_key="your_site_key"
114
+ )
115
+ ```
116
+
117
+ **Image CAPTCHA:**
118
+ ```python
119
+ from python_rucaptcha import ImageCaptcha
120
+
121
+ result = ImageCaptcha(api_key).captcha_handler(
122
+ image_link="https://example.com/captcha.jpg"
123
+ )
124
+ ```
125
+
126
+ **ALTCHA:**
127
+ ```python
128
+ from python_rucaptcha import AltchaCaptcha
129
+ from python_rucaptcha.core.enums import AltchaEnm
130
+
131
+ result = AltchaCaptcha(
132
+ rucaptcha_key=api_key,
133
+ websiteURL="https://example.com",
134
+ challengeURL="https://example.com/altcha/challenge",
135
+ method=AltchaEnm.AltchaTaskProxyless,
136
+ ).captcha_handler()
137
+ ```
138
+
139
+ **Using async:**
140
+ ```python
141
+ import asyncio
142
+ from python_rucaptcha import HCaptcha
143
+
144
+ async def solve():
145
+ result = await HCaptcha(api_key).aio_captcha_handler(
146
+ site_url="https://example.com",
147
+ site_key="abc123"
148
+ )
149
+ return result
150
+
151
+ token = asyncio.run(solve())
152
+ ```
153
+
154
+ ## Supported CAPTCHA Types
155
+
156
+ | CAPTCHA | Module | Description |
157
+ |---------|--------|-------------|
158
+ | reCAPTCHA v2/v3 | `ReCaptcha` | Google reCAPTCHA |
159
+ | hCaptcha | `HCaptcha` | hCaptcha challenge |
160
+ | Cloudflare Turnstile | `Turnstile` | Cloudflare protection |
161
+ | Image | `ImageCaptcha` | Type the text from image |
162
+ | Audio | `AudioCaptcha` | Listen and type audio |
163
+ | GeeTest | `GeeTest` | Chinese geetest puzzles |
164
+ | KeyCaptcha | `KeyCaptcha` | KeyCAPTCHA service |
165
+ | Amazon WAF | `AmazonWaf` | AWS WAF challenge |
166
+ | ALTCHA | `AltchaCaptcha` | ALTCHA challenge |
167
+ | Binance | `BinanceCaptcha` | Token-based Binance challenge |
168
+ | Grid | `GridCaptcha` | Select grid cells |
169
+ | Coordinates | `CoordinatesCaptcha` | Click on coordinates |
170
+ | And 20+ more | ... | See [full docs](https://andreidrang.github.io/python-rucaptcha/) |
171
+
172
+ ## Switching Services
173
+
174
+ Use the same code with different services:
175
+
176
+ ```python
177
+ from python_rucaptcha import HCaptcha
178
+ from python_rucaptcha.core.enums import ServiceEnm
179
+
180
+ # Use 2Captcha (default)
181
+ result = HCaptcha("2captcha_key").captcha_handler(...)
182
+
183
+ # Use RuCaptcha
184
+ result = HCaptcha("rucaptcha_key", service_type=ServiceEnm.RuCaptcha).captcha_handler(...)
185
+
186
+ # Use DeathByCaptcha
187
+ result = HCaptcha("dbc_user:dbc_pass", service_type=ServiceEnm.DeathByCaptcha).captcha_handler(...)
188
+ ```
189
+
190
+ ## Testing
191
+
192
+ ```bash
193
+ # Set your API key
194
+ export RUCAPTCHA_KEY="your_key_here"
195
+
196
+ # Run tests
197
+ make tests
198
+ ```
199
+
200
+ ## Documentation
201
+
202
+ For advanced usage, configuration options, and all CAPTCHA types, see the [full documentation](https://andreidrang.github.io/python-rucaptcha/).
203
+
204
+ ## Support
205
+
206
+ - **Telegram:** [pythoncaptcha](https://t.me/pythoncaptcha)
207
+ - **Email:** python-captcha@pm.me
208
+ - **Issues:** [GitHub Issues](https://github.com/AndreiDrang/python-rucaptcha/issues)
209
+
210
+ ## Changelog
211
+
212
+ See [Releases](https://github.com/AndreiDrang/python-rucaptcha/releases) for full changelog.
213
+
214
+ - **v6.0** - Refactored to use msgspec (faster), API v2, dropped Python 3.8
215
+ - **v5.3** - Added DeathByCaptcha support
216
+ - **v5.2** - Added audio CAPTCHA solving
@@ -69,7 +69,8 @@ keywords = [ "captcha",
69
69
  "vk-captcha",
70
70
  "fox-captcha",
71
71
  "temu-captcha",
72
- "friendly-captcha"
72
+ "friendly-captcha",
73
+ "binance-captcha"
73
74
  ]
74
75
  license = "MIT"
75
76
  classifiers = [
@@ -90,7 +91,7 @@ classifiers = [
90
91
  dependencies = [
91
92
  "requests>=2.21.0",
92
93
  "aiohttp>=3.9.2",
93
- "msgspec>=0.18,<0.20",
94
+ "msgspec>=0.18,<0.21",
94
95
  "tenacity>=8,<10"
95
96
  ]
96
97
 
@@ -98,6 +99,9 @@ dependencies = [
98
99
  where = ["src"]
99
100
  include = ["python_rucaptcha*"]
100
101
 
102
+ [tool.setuptools.package-data]
103
+ python_rucaptcha = ["core/data/*.json"]
104
+
101
105
  [tool.setuptools.dynamic]
102
106
  version = {attr = "python_rucaptcha.__version__"}
103
107
 
@@ -0,0 +1 @@
1
+ __version__ = "6.7.0"
@@ -0,0 +1,152 @@
1
+ from typing import Union, Optional
2
+
3
+ from .core.base import BaseCaptcha
4
+ from .core.enums import AltchaEnm
5
+
6
+
7
+ class AltchaCaptcha(BaseCaptcha):
8
+ def __init__(
9
+ self,
10
+ websiteURL: str,
11
+ method: Union[str, AltchaEnm] = AltchaEnm.AltchaTaskProxyless,
12
+ challengeURL: Optional[str] = None,
13
+ challengeJSON: Optional[str] = None,
14
+ proxyType: Optional[str] = None,
15
+ proxyAddress: Optional[str] = None,
16
+ proxyPort: Optional[int] = None,
17
+ proxyLogin: Optional[str] = None,
18
+ proxyPassword: Optional[str] = None,
19
+ *args,
20
+ **kwargs,
21
+ ):
22
+ """
23
+ The class is used to work with ALTCHA captcha.
24
+
25
+ Args:
26
+ rucaptcha_key: User API key
27
+ websiteURL: Full URL of the captcha page
28
+ method: Captcha type
29
+ challengeURL: Full URL of the page that contains ALTCHA challenge
30
+ challengeJSON: JSON-encoded ALTCHA challenge data
31
+ proxyType: Proxy type (http, https, socks4, socks5)
32
+ proxyAddress: Proxy IP address or hostname
33
+ proxyPort: Proxy port
34
+ proxyLogin: Proxy login
35
+ proxyPassword: Proxy password
36
+ kwargs: Not required params for task creation request
37
+
38
+ Examples:
39
+ >>> AltchaCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122",
40
+ ... websiteURL="https://example.com",
41
+ ... challengeURL="https://example.com/altcha/challenge.js",
42
+ ... method=AltchaEnm.AltchaTaskProxyless.value,
43
+ ... ).captcha_handler()
44
+ {
45
+ "errorId":0,
46
+ "status":"ready",
47
+ "solution":{
48
+ "token":"..."
49
+ },
50
+ "cost":"0.00145",
51
+ "ip":"1.2.3.4",
52
+ "createTime":1692863536,
53
+ "endTime":1692863556,
54
+ "solveCount":1,
55
+ "taskId": 73243152973,
56
+ }
57
+
58
+ >>> await AltchaCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122",
59
+ ... websiteURL="https://example.com",
60
+ ... challengeJSON='{"挑战数据"}',
61
+ ... method=AltchaEnm.AltchaTask.value,
62
+ ... proxyType="http",
63
+ ... proxyAddress="1.2.3.4",
64
+ ... proxyPort=8080,
65
+ ... ).aio_captcha_handler()
66
+ {
67
+ "errorId":0,
68
+ "status":"ready",
69
+ "solution":{
70
+ "token":"..."
71
+ },
72
+ "cost":"0.00145",
73
+ "ip":"1.2.3.4",
74
+ "createTime":1692863536,
75
+ "endTime":1692863556,
76
+ "solveCount":1,
77
+ "taskId": 73243152973,
78
+ }
79
+
80
+ Returns:
81
+ Dict with full server response
82
+
83
+ Notes:
84
+ https://rucaptcha.com/api-docs/altcha
85
+ """
86
+
87
+ super().__init__(method=method, *args, **kwargs)
88
+
89
+ # XOR validation: exactly one of challengeURL or challengeJSON must be provided
90
+ if not (bool(challengeURL) ^ bool(challengeJSON)):
91
+ raise ValueError(
92
+ "Exactly one of 'challengeURL' or 'challengeJSON' must be provided, not both or neither"
93
+ )
94
+
95
+ # Validate method
96
+ if method not in AltchaEnm.list_values():
97
+ raise ValueError(f"Invalid method parameter set, available - {AltchaEnm.list_values()}")
98
+
99
+ # Build task payload
100
+ task_data = {"websiteURL": websiteURL}
101
+
102
+ if challengeURL:
103
+ task_data["challengeURL"] = challengeURL
104
+
105
+ if challengeJSON:
106
+ task_data["challengeJSON"] = challengeJSON
107
+
108
+ # Add proxy params only for non-proxyless methods
109
+ if method == AltchaEnm.AltchaTask.value:
110
+ if not all([proxyType, proxyAddress, proxyPort]):
111
+ raise ValueError(
112
+ "Proxy parameters (proxyType, proxyAddress, proxyPort) are required for AltchaTask"
113
+ )
114
+ task_data.update(
115
+ {
116
+ "proxyType": proxyType,
117
+ "proxyAddress": proxyAddress,
118
+ "proxyPort": proxyPort,
119
+ }
120
+ )
121
+ if proxyLogin and proxyPassword:
122
+ task_data["proxyLogin"] = proxyLogin
123
+ task_data["proxyPassword"] = proxyPassword
124
+
125
+ self.create_task_payload["task"].update(task_data)
126
+
127
+ def captcha_handler(self, **kwargs) -> dict:
128
+ """
129
+ Sync solving method
130
+
131
+ Args:
132
+ kwargs: Parameters for the `requests` library
133
+
134
+ Returns:
135
+ Dict with full server response
136
+
137
+ Notes:
138
+ Check class docstirng for more info
139
+ """
140
+ return self._processing_response(**kwargs)
141
+
142
+ async def aio_captcha_handler(self) -> dict:
143
+ """
144
+ Async solving method
145
+
146
+ Returns:
147
+ Dict with full server response
148
+
149
+ Notes:
150
+ Check class docstirng for more info
151
+ """
152
+ return await self._aio_processing_response()