@2captcha/captcha-solver 1.0.0

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.
package/README.ru.md ADDED
@@ -0,0 +1,385 @@
1
+ [English](README.md) | [中国语文科](README.zh.md) | <b>[Русский](README.ru.md)</b>
2
+
3
+ # JavaScript модуль для 2Captcha API
4
+
5
+ ## Описание
6
+ Оболочка вокруг API сервиса [2captcha](https://2captcha.com/). Эта оболочка поддерживает решение следующих типов капч: reCAPTCHA V2, reCAPTCHA V3, hCaptcha, Arkose Labs FunCaptcha, image captcha, Coordinates (Click Captcha), Geetest, Geetest V4, Yandex Smart Captcha, Lemin captcha, Amazon WAF, Cloudflare Turnstile, Capy Puzzle, DataDome CAPTCHA, CyberSiARA, MTCaptcha, Friendly Captcha.
7
+
8
+ Также добавлена поддержка метода `bounding_box`. Метод ограничивающей рамки позволяет размечать данные на изображении. Этот метод можно использовать для разметки наборов данных или выделения любых объектов на изображении в соответствии с заданными инструкциями. Подробнее об использовании *Bounding Box Method* читайте в [документации](https://2captcha.com/2captcha-api#bounding_box).
9
+
10
+ [2captcha](https://2captcha.com/) это сервис, который решает множество различных типов капч. Эта библиотека служит оболочкой для API 2captcha, чтобы предоставить NodeJS простую функциональность, основанную на `promise`.
11
+
12
+ ## Поддерживаемые типы капч:
13
+ - ✅ google-recaptcha (reCAPTCHA v2 / reCAPTCHA v3)
14
+ - ✅ hCaptcha
15
+ - ✅ Arkose Labs FunCaptcha
16
+ - ✅ Image captchas. (`base64` format)
17
+ - ✅ Geetest
18
+ - ✅ Geetest v4
19
+ - ✅ Yandex Smart Captcha
20
+ - ✅ Lemin Cropped Captcha
21
+ - ✅ Cloudflare Turnstile
22
+ - ✅ Amazon WAF Captcha
23
+ - ✅ Capy Puzzle
24
+ - ✅ Coordinates (Click Captcha)
25
+ - ⬜ Audio Recogntion
26
+ - ✅ DataDome CAPTCHA
27
+ - ✅ CyberSiARA
28
+ - ✅ MTCaptcha
29
+ - ✅ Friendly Captcha
30
+ - ✅ Bounding Box Method
31
+
32
+
33
+ ## Установка
34
+
35
+ ```sh
36
+ npm install @2captcha/captcha-solver
37
+ ```
38
+ ```sh
39
+ yarn add @2captcha/captcha-solver
40
+ ```
41
+
42
+ ## Примеры использования
43
+
44
+
45
+ ### reCAPTCHA:
46
+ ```js
47
+ const Captcha = require("@2captcha/captcha-solver")
48
+ // Новый экземпляр "solver" со значением вашего ключа 2captcha API
49
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
50
+
51
+ // Решение reCAPTCHA, на демо странице содержащей reCAPTCHA V2
52
+ solver.recaptcha({
53
+ pageurl: 'https://2captcha.com/demo/recaptcha-v2',
54
+ googlekey: '6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u'
55
+ })
56
+ .then((res) => {
57
+ console.log(res);
58
+ })
59
+ .catch((err) => {
60
+ console.log(err);
61
+ })
62
+ ```
63
+
64
+ ### hCaptcha:
65
+ ```js
66
+ const Captcha = require("@2captcha/captcha-solver")
67
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
68
+
69
+ solver.hcaptcha({
70
+ pageurl: "https://2captcha.com/demo/hcaptcha?difficulty=moderate",
71
+ sitekey: "b76cd927-d266-4cfb-a328-3b03ae07ded6"
72
+ })
73
+ .then((res) => {
74
+ console.log(res);
75
+ })
76
+ .catch((err) => {
77
+ console.log(err);
78
+ })
79
+ ```
80
+
81
+ ### Arkose Labs FunCaptcha:
82
+ ```js
83
+ const Captcha = require("@2captcha/captcha-solver")
84
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
85
+
86
+ solver.funCaptcha({
87
+ pageurl: "https://funcaptcha.com/tile-game-lite-mode/fc/api/nojs/?pkey=804380F4-6844-FFA1-ED4E-5877CA1F1EA4&lang=en",
88
+ publickey: "804380F4-6844-FFA1-ED4E-5877CA1F1EA4"
89
+ })
90
+ .then((res) => {
91
+ console.log(res);
92
+ })
93
+ .catch((err) => {
94
+ console.log(err);
95
+ })
96
+ ```
97
+
98
+ ### Image captcha:
99
+ ```js
100
+ const Captcha = require("@2captcha/captcha-solver")
101
+ const fs = require("fs")
102
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
103
+
104
+ // Получаем содержимое файла в формате base64
105
+ const imageBase64 = fs.readFileSync("./tests/media/imageCaptcha_6e584.png", "base64")
106
+
107
+ solver.imageCaptcha({
108
+ body: imageBase64,
109
+ numeric: 4,
110
+ min_len: 5,
111
+ max_len: 5
112
+ })
113
+ .then((res) => {
114
+ console.log(res);
115
+ })
116
+ .catch((err) => {
117
+ console.log(err);
118
+ })
119
+ ```
120
+
121
+
122
+ ### GeeTest Captcha:
123
+ ```js
124
+ const Captcha = require("@2captcha/captcha-solver")
125
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
126
+
127
+ // Значение `challenge` является динамическим
128
+ // Читайте подробнее о `challenge` на странице https://2captcha.com/p/geetest
129
+ solver.geetest({
130
+ pageurl: 'https://2captcha.com/demo/geetest',
131
+ gt: '81388ea1fc187e0c335c0a8907ff2625',
132
+ challenge: '<you need to get a new challenge value each time>'
133
+ })
134
+ .then((res) => {
135
+ console.log(res);
136
+ })
137
+ .catch((err) => {
138
+ console.log(err);
139
+ })
140
+ ```
141
+
142
+ ### GeeTest V4 Captcha:
143
+ ```js
144
+ const Captcha = require("@2captcha/captcha-solver")
145
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
146
+
147
+ solver.geetestV4({
148
+ pageurl: 'https://2captcha.com/demo/geetest-v4',
149
+ captcha_id: 'e392e1d7fd421dc63325744d5a2b9c73'
150
+ })
151
+ .then((res) => {
152
+ console.log(res);
153
+ })
154
+ .catch((err) => {
155
+ console.log(err);
156
+ })
157
+ ```
158
+
159
+ ### Yandex Smart Captcha:
160
+ ```js
161
+ const Captcha = require("@2captcha/captcha-solver")
162
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
163
+
164
+ solver.yandexSmart({
165
+ pageurl: "https://captcha-api.yandex.ru/demo",
166
+ sitekey: "FEXfAbHQsToo97VidNVk3j4dC74nGW1DgdxjtNB9"
167
+ })
168
+ .then((res) => {
169
+ console.log(res);
170
+ })
171
+ .catch((err) => {
172
+ console.log(err);
173
+ })
174
+ ```
175
+
176
+ ### Lemin captcha:
177
+ ```js
178
+ const Captcha = require("@2captcha/captcha-solver")
179
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
180
+
181
+ solver.lemin({
182
+ pageurl:'https://dashboard.leminnow.com/auth/login',
183
+ captcha_id: 'CROPPED_099216d_34698cb7b8574265925f493cbcb3df4d',
184
+ div_id: 'lemin-cropped-captcha',
185
+ api_server: 'https://api.leminnow.com/captcha/v1/cropped'
186
+ })
187
+ .then((res) => {
188
+ console.log(res);
189
+ })
190
+ .catch((err) => {
191
+ console.log(err);
192
+ })
193
+ ```
194
+
195
+ ### Cloudflare Turnstile:
196
+ ```js
197
+ const Captcha = require("@2captcha/captcha-solver")
198
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
199
+
200
+ solver.cloudflareTurnstile({
201
+ pageurl: "https://app.nodecraft.com/login",
202
+ sitekey: "0x4AAAAAAAAkg0s3VIOD10y4"
203
+ })
204
+ .then((res) => {
205
+ console.log(res);
206
+ })
207
+ .catch((err) => {
208
+ console.log(err);
209
+ })
210
+ ```
211
+
212
+ ### Amazon WAF Captcha (AWS WAF):
213
+ ```js
214
+ const Captcha = require("@2captcha/captcha-solver")
215
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
216
+
217
+ // INFO: Значение `context` является динамическим, необходимо каждый раз брать фактическое значение со страницы с капчей.
218
+ solver.amazonWaf({
219
+ pageurl: "https://non-existent-example.execute-api.us-east-1.amazonaws.com/latest",
220
+ sitekey: "AQIDAHjcYu/GjX+QlghicBgQ/7bFaQZ+m5FKCMDnO+vTbNg96AHMDLodoefdvyOnsHMRt...",
221
+ context: "9BUgmlm48F92WUoqv97a49ZuEJJ50TCk9MVr3C7WMtQ0X6flVbufM4n8mjFLmbLVAPgaQ...",
222
+ iv: "CgAHbCe2GgAAAAAj",
223
+ })
224
+ .then((res) => {
225
+ console.log(res);
226
+ })
227
+ .catch((err) => {
228
+ console.log(err);
229
+ })
230
+ ```
231
+
232
+ ### Capy Puzzle
233
+ ```js
234
+ const Captcha = require("@2captcha/captcha-solver")
235
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
236
+
237
+ solver.capyPuzzle({
238
+ pageurl: "https://www.capy.me/account/register/",
239
+ captchakey: "PUZZLE_Cme4hZLjuZRMYC3uh14C52D3uNms5w"
240
+ })
241
+ .then((res) => {
242
+ console.log(res);
243
+ })
244
+ .catch((err) => {
245
+ console.log(err);
246
+ })
247
+ ```
248
+
249
+ ### DataDome CAPTCHA
250
+ ```js
251
+ const Captcha = require("@2captcha/captcha-solver")
252
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
253
+
254
+
255
+ solver.dataDome({
256
+ pageurl: "https://rendezvousparis.hermes.com/client/register",
257
+ captcha_url: "https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAAAAMAEuQtkf4k1c0ABZhYZA%3D%3D&hash=789361B674144528D0B7EE76B35826&cid=mY4z7GNmh7Nt1lAFwpbNHAOcWPhyPgjHD2K1Pm~Od1iEKYLUnK3t7N2ZGUj8OqDK65cnwJHtHwd~t902vlwpSBA5l4ZHbS1Qszv~jEuEUJNQ_jMAjar2Kj3kq20MRJYh&t=fe&referer=https%3A%2F%2Frendezvousparis.hermes.com%2Fclient%2Fregister&s=40119&e=67fef144ac1a54dbd7507776367d2f9d5e36ec3add17fa22f3cb881db8385838",
258
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36",
259
+ proxy: "login:password@1.2.3.4:8888", // The (Username : Password @ Address : Port) of our chosen proxy
260
+ proxytype: "http" // The 'Type' of proxy, http, https, socks, ect.
261
+ })
262
+ .then((res) => {
263
+ console.log(res);
264
+ })
265
+ .catch((err) => {
266
+ console.log(err);
267
+ })
268
+ ```
269
+
270
+ ### CyberSiARA
271
+ ```js
272
+ const Captcha = require("@2captcha/captcha-solver")
273
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
274
+
275
+
276
+ solver.cyberSiARA({
277
+ pageurl: "https://www.cybersiara.com/book-a-demo",
278
+ master_url_id: "OXR2LVNvCuXykkZbB8KZIfh162sNT8S2",
279
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36"
280
+ })
281
+ .then((res) => {
282
+ console.log(res);
283
+ })
284
+ .catch((err) => {
285
+ console.log(err);
286
+ })
287
+ ```
288
+
289
+ ### MTCaptcha
290
+ ```js
291
+ const Captcha = require("@2captcha/captcha-solver")
292
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
293
+
294
+
295
+ solver.mtCaptcha({
296
+ pageurl: "https://service.mtcaptcha.com/mtcv1/demo/index.html",
297
+ sitekey: "MTPublic-DemoKey9M"
298
+ })
299
+ .then((res) => {
300
+ console.log(res);
301
+ })
302
+ .catch((err) => {
303
+ console.log(err);
304
+ })
305
+ ```
306
+
307
+ ### Friendly Captcha
308
+
309
+ Используйте этот метод, чтобы решить Friendly Captcha и получить токен для обхода защиты.
310
+
311
+ > **Важно:**Для успешного использования полученного токена, на странице не должен быть загружен виджет капчи. Для этого вам нужно прервать запрос к `/friendcaptcha/...module.min.js` на странице. Когда виджет капчи уже загружен на страницу, велика вероятность, что полученный токен не сработает.
312
+
313
+ ```js
314
+ solver.friendlyCaptcha({
315
+ pageurl: "https://geizhals.de/?liftban=1&from=/455973138?fsean=5901747021356",
316
+ sitekey: "FCMST5VUMCBOCGQ9"
317
+ })
318
+ .then((res) => {
319
+ console.log(res);
320
+ })
321
+ .catch((err) => {
322
+ console.log(err);
323
+ })
324
+ ```
325
+
326
+ ### Coordinates (Click Captcha):
327
+ ```js
328
+ const Captcha = require("@2captcha/captcha-solver")
329
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
330
+ const imageBase64 = fs.readFileSync("./tests/media/hCaptchaImage.jpg", "base64")
331
+
332
+ solver.coordinates({
333
+ body: imageBase64,
334
+ textinstructions: 'Select all photos containing the boat'
335
+ })
336
+ .then((res) => {
337
+ console.log(res);
338
+ })
339
+ .catch((err) => {
340
+ console.log(err);
341
+ })
342
+ ```
343
+
344
+ ### Bounding Box Method:
345
+ *Bounding Box Method* позволяет выбирать объекты, указанные на изображении. Для этого вам необходимо передать инструкции по разметке. Инструкции могут быть отправлены в виде текста или изображения, закодированного в формате `base64`. Обязательно необходимо передать хотя бы одну инструкцию `imginstructions` или `textinstructions`.
346
+
347
+ ```js
348
+ const Captcha = require("@2captcha/captcha-solver")
349
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
350
+
351
+ solver.boundingBox({
352
+ image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR4AAACwCAIAAAB...",
353
+ textinstructions: "Обведите все машины на изображении.",
354
+ })
355
+ .then((res) => {
356
+ console.log(res);
357
+ })
358
+ .catch((err) => {
359
+ console.log(err);
360
+ })
361
+ ```
362
+
363
+ ### Proxy:
364
+ ```js
365
+ const Captcha = require("@2captcha/captcha-solver")
366
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
367
+
368
+ solver.recaptcha({
369
+ pageurl: 'https://2captcha.com/demo/recaptcha-v2',
370
+ googlekey: '6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u',
371
+ proxy: "login:password@1.2.3.4:8888", // Параметры используемого вами прокси сервера
372
+ proxytype: "HTTP" // Тип используемого прокси: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
373
+ })
374
+ .then((res) => {
375
+ console.log(res)
376
+ })
377
+ .catch((err) => {
378
+ console.error(err.message)
379
+ })
380
+ ```
381
+
382
+ ## Полезные статьи
383
+ * [Как решать капчу Geetest v4](https://2captcha.com/ru/blog/geetest-v4-obkhod)
384
+ * [Автоматическое решение reCAPTCHA V3 - инструкция для разработчиков и заказчиков](https://2captcha.com/ru/blog/avtomaticheskoe-reshenie-recaptcha-v3)
385
+ * <a href="./docs/hcaptcha.md">Поиск значения `sitekey` для hCaptcha</a>