ruby-2captcha 1.1.6 → 1.2.1

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec_status +16 -7
  3. data/.ruby-version +1 -1
  4. data/Gemfile.lock +1 -1
  5. data/README.md +222 -4
  6. data/README.ru.md +227 -0
  7. data/api_2captcha.gemspec +1 -1
  8. data/examples/alibaba_example.rb +16 -0
  9. data/examples/altcha_example.rb +12 -0
  10. data/examples/amazon_waf_example.rb +14 -0
  11. data/examples/basilisk_example.rb +15 -0
  12. data/examples/binance_example.rb +17 -0
  13. data/examples/canvas_example.rb +13 -0
  14. data/examples/captchafox_example.rb +20 -0
  15. data/examples/capy_example.rb +11 -0
  16. data/examples/cloudflare_turnstile_example.rb +15 -0
  17. data/examples/coordinates_example.rb +12 -0
  18. data/examples/cut_captcha_example.rb +11 -0
  19. data/examples/cyber_siara_example.rb +10 -0
  20. data/examples/datadome_example.rb +12 -0
  21. data/examples/drag_drop_example.rb +24 -0
  22. data/examples/friendly_captcha_example.rb +10 -0
  23. data/examples/funcaptcha_example.rb +10 -0
  24. data/examples/geetest_example.rb +12 -0
  25. data/examples/geetest_v4_example.rb +10 -0
  26. data/examples/hcaptcha_example.rb +10 -0
  27. data/examples/hunt_example.rb +17 -0
  28. data/examples/imperva_example.rb +20 -0
  29. data/examples/key_captcha_example.rb +13 -0
  30. data/examples/lemin_example.rb +12 -0
  31. data/examples/media/drag_drop/background.jpeg +0 -0
  32. data/examples/media/drag_drop/image1.jpeg +0 -0
  33. data/examples/media/drag_drop/image2.jpeg +0 -0
  34. data/examples/media/temu/body.png +0 -0
  35. data/examples/media/temu/part1.png +0 -0
  36. data/examples/media/temu/part2.png +0 -0
  37. data/examples/media/temu/part3.png +0 -0
  38. data/examples/mt_captcha_example.rb +10 -0
  39. data/examples/normal_captcha_example.rb +4 -2
  40. data/examples/prosopo_example.rb +16 -0
  41. data/examples/recaptcha_v2_example.rb +1 -1
  42. data/examples/recaptcha_v3_example.rb +18 -0
  43. data/examples/rotate_example.rb +13 -0
  44. data/examples/temu_example.rb +28 -0
  45. data/examples/text_example.rb +23 -0
  46. data/examples/tspd_example.rb +19 -0
  47. data/examples/vkcaptcha_example.ru +10 -0
  48. data/examples/vkimage_example.rb +10 -0
  49. data/examples/yandex_example.rb +10 -0
  50. data/examples/yidun_example.rb +15 -0
  51. data/howto.txt +8 -0
  52. data/lib/api_2captcha/client.rb +87 -30
  53. data/lib/api_2captcha/version.rb +1 -1
  54. metadata +49 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3cf34c705f05cac002afa61dbfe4ded7b7e1f07a579fa0d2e98c52ec1972ebc
4
- data.tar.gz: 7aeb0c18eb4f7136278ef3ab528312eced958cd4ef1ebd2ee33a44296e4ed416
3
+ metadata.gz: 6e27af7b5ab7e5e7a117b7598d8eb609ca10bee60174078691eda86265e8d464
4
+ data.tar.gz: 21dcd54bfe95f730b5887e41bdbdec5baca72eb915e8b8125f1006c59821640b
5
5
  SHA512:
6
- metadata.gz: c092dcb03fc11e1de8aff2a41b7b1b8908ee19e66dd643d8aaf4dd12cdab9d920e68a60b6f63c55e6ea9271b93f8b9d54aa3ea1d0991e8f11ae9cbad48d1b813
7
- data.tar.gz: 7c42d06519aa623dcf5652d036bc85864f1df0725d913c3c7be2d3be2f7b8502367ed802ccba7f3908a3f2bf711840a50e36a54c53b4a35df0b9699cb008fc4b
6
+ metadata.gz: 69eeb331f6d5104521ffceaaa3268cab0c48c502e9e390d9e6d259cdfb568027f2ffbd82cbcf445797663fd6f9deaf89537a88e50e42459ca70df6b53af54a79
7
+ data.tar.gz: c25f4db3a71a56f95846964081f986765007a38a493917d496e3e21f2a6b974b2917788b35265d2c622a13f99bac620e89cefb121890b099da91fade1759fa1c
data/.rspec_status CHANGED
@@ -1,7 +1,16 @@
1
- example_id | status | run_time |
2
- ---------------------------------- | ------ | --------------------- |
3
- ./spec/api_2captcha_spec.rb[1:1] | passed | 0.04326 seconds |
4
- ./spec/api_2captcha_spec.rb[1:2:1] | passed | 0.00121 seconds |
5
- ./spec/api_2captcha_spec.rb[1:3:1] | passed | 3.15 seconds |
6
- ./spec/api_2captcha_spec.rb[1:4:1] | passed | 2 minutes 0.2 seconds |
7
- ./spec/api_2captcha_spec.rb[1:5:1] | passed | 0.26142 seconds |
1
+ example_id | status | run_time |
2
+ ----------------------------------- | ------- | --------------------- |
3
+ ./spec/api_2captcha_spec.rb[1:1] | passed | 0.00056 seconds |
4
+ ./spec/api_2captcha_spec.rb[1:2:1] | passed | 0.00041 seconds |
5
+ ./spec/api_2captcha_spec.rb[1:3:1] | passed | 1.52 seconds |
6
+ ./spec/api_2captcha_spec.rb[1:4:1] | passed | 23.45 seconds |
7
+ ./spec/api_2captcha_spec.rb[1:5:1] | passed | 0.60409 seconds |
8
+ ./spec/api_2captcha_spec.rb[1:6:1] | passed | 12.42 seconds |
9
+ ./spec/api_2captcha_spec.rb[1:7:1] | passed | 1.37 seconds |
10
+ ./spec/api_2captcha_spec.rb[1:8:1] | passed | 1 minute 4.24 seconds |
11
+ ./spec/api_2captcha_spec.rb[1:9:1] | unknown | |
12
+ ./spec/api_2captcha_spec.rb[1:10:1] | unknown | |
13
+ ./spec/api_2captcha_spec.rb[1:11:1] | unknown | |
14
+ ./spec/api_2captcha_spec.rb[1:12:1] | unknown | |
15
+ ./spec/api_2captcha_spec.rb[1:13:1] | unknown | |
16
+ ./spec/api_2captcha_spec.rb[1:14:1] | passed | 0.29802 seconds |
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.0
1
+ 3.2.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-2captcha (1.1.5)
4
+ ruby-2captcha (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -44,6 +44,19 @@ Examples of API requests for different captcha types are available on the [Ruby
44
44
  - [Cutcaptcha](#cutcaptcha)
45
45
  - [Tencent](#tencent)
46
46
  - [atbCAPTCHA](#atbcaptcha)
47
+ - [Prosopo](#prosopo)
48
+ - [Captchafox](#captchafox)
49
+ - [Temu](#temu)
50
+ - [VK Image](#vk-image)
51
+ - [VK Captcha](#vk-captcha)
52
+ - [Altcha Captcha](#altcha-captcha)
53
+ - [Hunt Captcha](#hunt-captcha)
54
+ - [Tspd](#tspd)
55
+ - [Basilisk](#basilisk)
56
+ - [Alibaba](#alibaba)
57
+ - [Yidun](#yidun)
58
+ - [Drag & Drop Captcha](#drag--drop-captcha)
59
+ - [Imperva (Incapsula)](#imperva-incapsula)
47
60
  - [Other methods](#other-methods)
48
61
  - [send / get_result](#send--get_result)
49
62
  - [balance](#balance)
@@ -93,7 +106,7 @@ client.api_key = "YOUR_API_KEY"
93
106
 
94
107
  |Option |Default value|Description |
95
108
  |----------------|-------------|------------------------------------------------------------------------|
96
- |soft_id |4584 |your software ID obtained after publishing in [2captcha sofware catalog]|
109
+ |soft_id |4584 |your software ID obtained after publishing in [2captcha software catalog]|
97
110
  |callback |- |URL of your web-sever that receives the captcha recognition result. The URl should be first registered in [pingback settings] of your account|
98
111
  |default_timeout |120 |Timeout in seconds for all captcha types except reCAPTCHA. Defines how long the module tries to get the answer from `res.php` API endpoint|
99
112
  |polling_interval|10 |Interval in seconds between requests to `res.php` API endpoint, setting values less than 5 seconds is not recommended|
@@ -110,7 +123,7 @@ When you submit any image-based captcha use can provide additional options to he
110
123
  | Option | Default Value | Description |
111
124
  | ------------- | ------------- | -------------------------------------------------------------------------------------------------- |
112
125
  | numeric | 0 | Defines if captcha contains numeric or other symbols [see more info in the API docs][normal_post] |
113
- | min_len | 0 | minimal answer lenght |
126
+ | min_len | 0 | minimal answer length |
114
127
  | max_len | 0 | maximum answer length |
115
128
  | phrase | 0 | defines if the answer contains multiple words or not |
116
129
  | case_sensitive| 0 | defines if the answer is case sensitive |
@@ -494,6 +507,211 @@ result = client.atb_captcha({
494
507
  })
495
508
  ```
496
509
 
510
+ ### Prosopo
511
+
512
+ <sup>[API method description.](https://2captcha.com/2captcha-api#prosopo-procaptcha)</sup>
513
+
514
+ Token-based method for automated solving of Prosopo.
515
+
516
+ ```ruby
517
+ result = client.prosopo({
518
+ pageurl: "https://www.twickets.live/",
519
+ sitekey: "5EZVvsHMrKCFKp5NYNoTyDjTjetoVo1Z4UNNbTwJf1GfN6Xm"
520
+ })
521
+ ```
522
+
523
+ ### Captchafox
524
+
525
+ <sup>[API method description.](https://2captcha.com/2captcha-api#captchafox)</sup>
526
+
527
+ Token-based method for automated solving of Captchafox.
528
+
529
+ ```ruby
530
+ result = client.captchafox({
531
+ sitekey: "sitekey",
532
+ pageurl: "https://pageurl/",
533
+ api_server: "https://mam.example.com",
534
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/131.0.0.0 Safari/537.36",
535
+ proxytype: "socks5",
536
+ proxy: "proxyuser:strongPassword@123.123.123.123:3128"
537
+ })
538
+ ```
539
+
540
+ ### Temu
541
+
542
+ <sup>[API method description.](https://2captcha.com/2captcha-api#temucaptcha)</sup>
543
+
544
+ Token-based method for automated solving of Temu.
545
+
546
+ ```ruby
547
+ result = client.temu({
548
+ body: bodyStr,
549
+ part1: part1Str,
550
+ part2: part2Str,
551
+ part3: part3Str,
552
+ })
553
+ ```
554
+
555
+
556
+ ### VK Image
557
+
558
+ <sup>[API method description.](https://2captcha.com/2captcha-api#vk-captcha)</sup>
559
+
560
+ We use the body (image in base64 format) or file (image as file) and steps parameters.
561
+ You can get both values from the response to the request https://api.vk.com/method/captchaNotRobot.getContent?v={API_VER} when loading the captcha widget on the page.
562
+
563
+ ```ruby
564
+ result = client.vkimage({
565
+ image: '/9j/4AAQSkZJRgABAQAAAQABAAD/2...',
566
+ steps: '[5,19,14,14,6,4,8...]'
567
+ })
568
+ ```
569
+
570
+ ### VK Captcha
571
+
572
+ <sup>[API method description.](https://2captcha.com/2captcha-api#vk-captcha)</sup>
573
+
574
+ Token-based method requires redirect_uri parameter, as well as proxy and userAgent. The value of the redirect_uri parameter can be found in the response to requests to the VK API that return captchas.
575
+
576
+ ```ruby
577
+ result = client.vkcaptcha({
578
+ redirect_uri: 'https://id.vk.com/not_robot_captcha?domain=vk.com&session_token=eyJ....HGsc5B4LyvjA&variant=popup&blank=1',
579
+ userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36'
580
+ })
581
+ ```
582
+
583
+ ### Altcha Captcha
584
+ <sup>[API method description.](https://2captcha.com/2captcha-api#altchacaptcha)</sup>
585
+
586
+ Use this method to solve Altcha Captcha. Returns a token.
587
+
588
+ ```ruby
589
+ result = client.altcha({
590
+ pageurl: 'https://mysite.com/page/with/altcha',
591
+ challenge: '{"algorithm":"SHA-256","challenge":"a4c9d8e7f1b23a6c...","signature":"7b3e2a9d5c8f1046e2d91c3a..."}'
592
+ # or:
593
+ # challenge_url: 'https://example.com/altcha-challenge'
594
+ })
595
+ ```
596
+
597
+ ### Hunt Captcha
598
+
599
+ <sup>[API method description.](https://2captcha.com/2captcha-api#hunt)</sup>
600
+
601
+ Token-based method for automated solving of Hunt captcha. Uses a two-step workflow: the first request without `data` returns an X-HD fingerprint; after sending it to the site and receiving `meta.token`, a second request with `data` returns the final token.
602
+
603
+ > [!IMPORTANT]
604
+ > To solve the Hunt captcha, you must use a proxy. It is recommended to use [residential proxies].
605
+
606
+ ```ruby
607
+ result = client.hunt({
608
+ pageurl: "https://example.com/page-with-hunt",
609
+ api_get_lib: "https://example.com/hd-api/external/apps/app-id/api.js",
610
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
611
+ proxytype: "http",
612
+ proxy: "proxyuser:strongPassword@123.123.123.123:3128"
613
+ })
614
+ ```
615
+
616
+ ### Tspd
617
+
618
+ <sup>[API method description.](https://2captcha.com/2captcha-api#tspd)</sup>
619
+
620
+ Use this method to solve TSPD captcha. Returns cookies. A proxy is required — there is no proxyless variant.
621
+
622
+ > [!IMPORTANT]
623
+ > To solve the TSPD captcha, you must use a proxy. The same outbound IP address must be maintained across all stages: getting cookies, solving the task, and using the result.
624
+
625
+ ```ruby
626
+ result = client.tspd({
627
+ pageurl: "https://example.com/page-with-tspd",
628
+ tspd_cookie: "TS...",
629
+ html_page_base64: "PGh0bWw+...",
630
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
631
+ proxytype: "http",
632
+ proxy: "proxyuser:strongPassword@123.123.123.123:3128"
633
+ })
634
+ ```
635
+
636
+ ### Basilisk
637
+
638
+ <sup>[API method description.](https://2captcha.com/2captcha-api#basilisk)</sup>
639
+
640
+ Token-based method for automated solving of Basilisk captcha.
641
+
642
+ ```ruby
643
+ result = client.basilisk({
644
+ pageurl: "https://example.com/page-with-basilisk",
645
+ sitekey: "SITE_KEY"
646
+ })
647
+ ```
648
+
649
+ ### Alibaba
650
+
651
+ <sup>[API method description.](https://2captcha.com/2captcha-api#alibaba)</sup>
652
+
653
+ Token-based method for automated solving of Alibaba captcha.
654
+
655
+ ```ruby
656
+ result = client.alibaba({
657
+ pageurl: "https://example.com/page-with-alibaba",
658
+ scene_id: "SCENE_ID",
659
+ prefix: "PREFIX"
660
+ })
661
+ ```
662
+
663
+ ### Yidun
664
+
665
+ <sup>[API method description.](https://2captcha.com/2captcha-api#yidun)</sup>
666
+
667
+ Token-based method for automated solving of Yidun captcha.
668
+
669
+ ```ruby
670
+ result = client.yidun({
671
+ pageurl: "https://example.com/page-with-yidun",
672
+ sitekey: "SITE_KEY"
673
+ })
674
+ ```
675
+
676
+ ### Drag & Drop Captcha
677
+
678
+ <sup>[API method description.](https://2captcha.com/2captcha-api#drag-and-drop-captcha)</sup>
679
+
680
+ Use this method to solve captchas where one or more images need to be dragged onto specific positions of a background image. `body` is the background image and `images` is an array of the images to drag onto it, both Base64-encoded — read the files and encode them yourself, as shown below. The order of `images` matters: the result uses the same order.
681
+
682
+ The result is a string with coordinates for each image from `images`, separated by `|`. An image that doesn't need to be moved comes back as the literal string `null`.
683
+
684
+ ```ruby
685
+ result = client.drag_drop({
686
+ body: bodyStr,
687
+ images: [image1Str, image2Str],
688
+ textinstructions: "Drag the images to proper position"
689
+ })
690
+ ```
691
+
692
+ ### Imperva (Incapsula)
693
+
694
+ <sup>[API method description.](https://2captcha.com/2captcha-api#imperva)</sup>
695
+
696
+ Cookie-based method for automated solving of Imperva (Incapsula) captcha. `incapsula_script_url` and `incapsula_cookies` are generated dynamically and may differ on each page load. Optionally pass `reese84_url_endpoint` if the site uses Reese84, and `userAgent` of the browser that opens the page.
697
+
698
+ The result contains cookies for each domain in `request.domains`, which should be sent to the target site. If `request.headers.User-Agent` is returned, use the same User-Agent in requests to the site.
699
+
700
+ > [!IMPORTANT]
701
+ > To solve the Imperva captcha, you must use a proxy. It is recommended to use [residential proxies].
702
+
703
+ ```ruby
704
+ result = client.imperva({
705
+ pageurl: "https://example.com/page-with-imperva",
706
+ incapsula_script_url: "/_Incapsula_Resource?SWUDNSAI=31&xinfo=1",
707
+ incapsula_cookies: "visid_incap_123456=sample; incap_ses_123_123456=sample",
708
+ reese84_url_endpoint: "https://example.com/_Incapsula_Resource?reese84=1",
709
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
710
+ proxytype: "http",
711
+ proxy: "proxyuser:strongPassword@123.123.123.123:3128"
712
+ })
713
+ ```
714
+
497
715
  ## Other methods
498
716
 
499
717
  ### send / get_result
@@ -600,11 +818,11 @@ The graphics and trademarks included in this repository are not covered by the M
600
818
 
601
819
  <!-- Shared links -->
602
820
  [2Captcha]: https://2captcha.com/
603
- [2captcha sofware catalog]: https://2captcha.com/software
821
+ [2captcha software catalog]: https://2captcha.com/software
604
822
  [pingback settings]: https://2captcha.com/setting/pingback
605
823
  [normal_post]: https://2captcha.com/2captcha-api#normal_post
606
824
  [list of supported languages]: https://2captcha.com/2captcha-api#language
607
825
  [Buy residential proxies]: https://2captcha.com/proxy/residential-proxies
608
826
  [Quick start]: https://2captcha.com/proxy?openAddTrafficModal=true
609
827
  [examples]: ./examples/
610
- [residential proxies]: https://2captcha.com/proxy/residential-proxies
828
+ [residential proxies]: https://2captcha.com/proxy/residential-proxies
data/README.ru.md CHANGED
@@ -41,6 +41,19 @@
41
41
  - [Cutcaptcha](#cutcaptcha)
42
42
  - [Tencent](#tencent)
43
43
  - [atbCAPTCHA](#atbcaptcha)
44
+ - [Prosopo](#prosopo)
45
+ - [Captchafox](#captchafox)
46
+ - [Temu](#temu)
47
+ - [VK Captcha](#vk-captcha)
48
+ - [Altcha Captcha](#altcha-captcha)
49
+ - [Binancecaptcha](#binancecaptcha)
50
+ - [Hunt Captcha](#hunt-captcha)
51
+ - [Tspd](#tspd)
52
+ - [Basilisk](#basilisk)
53
+ - [Alibaba](#alibaba)
54
+ - [Yidun](#yidun)
55
+ - [Drag & Drop Captcha](#drag--drop-captcha)
56
+ - [Imperva (Incapsula)](#imperva-incapsula)
44
57
  - [Другие методы](#другие-методы)
45
58
  - [send / get_result](#send--get_result)
46
59
  - [Баланс](#баланс)
@@ -476,6 +489,220 @@ result = client.atb_captcha({
476
489
  })
477
490
  ```
478
491
 
492
+ ### Prosopo
493
+
494
+ <sup>[Описание метода API.](https://2captcha.com/2captcha-api#prosopo-procaptcha)</sup>
495
+
496
+ Основанный на токенах метод автоматизированного решения капчи Prosopo.
497
+
498
+ ```ruby
499
+ result = client.prosopo({
500
+ pageurl: "https://www.twickets.live/",
501
+ sitekey: "5EZVvsHMrKCFKp5NYNoTyDjTjetoVo1Z4UNNbTwJf1GfN6Xm"
502
+ })
503
+ ```
504
+
505
+ ### Captchafox
506
+
507
+ <sup>[Описание метода API.](https://2captcha.com/2captcha-api#captchafox)</sup>
508
+
509
+ Основанный на токенах метод автоматизированного решения капчи Captchafox.
510
+
511
+ ```ruby
512
+ result = client.captchafox({
513
+ sitekey: "sitekey",
514
+ pageurl: "https://pageurl/",
515
+ api_server: "https://mam.example.com",
516
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/131.0.0.0 Safari/537.36",
517
+ proxytype: "socks5",
518
+ proxy: "proxyuser:strongPassword@123.123.123.123:3128"
519
+ })
520
+ ```
521
+
522
+ ### Temu
523
+
524
+ <sup>[API method description.](https://2captcha.com/2captcha-api#temucaptcha)</sup>
525
+
526
+ Основанный на токенах метод автоматизированного решения капчи Temu.
527
+
528
+ ```ruby
529
+ result = client.temu({
530
+ body: bodyStr,
531
+ part1: part1Str,
532
+ part2: part2Str,
533
+ part3: part3Str,
534
+ ### VK Image
535
+
536
+ <sup>[API описание метода.](https://2captcha.com/2captcha-api#vkcaptcha)</sup>
537
+
538
+ Мы используем текст (изображение в формате base64) или файл (изображение как файл) и параметры steps.
539
+ Вы можете получить оба значения из ответа на запрос https://api.vk.com/method/captchaNotRobot.getContent?v={API_VER} при загрузке виджета captcha на страницу.
540
+
541
+ ```ruby
542
+ result = client.vkimage({
543
+ image: '/9j/4AAQSkZJRgABAQAAAQABAAD/2...',
544
+ steps: '[5,19,14,14,6,4,8...]'
545
+ })
546
+ ```
547
+
548
+ ### VK Captcha
549
+
550
+ <sup>[API описание метода.](https://2captcha.com/2captcha-api#vkcaptcha)</sup>
551
+
552
+ Для метода, основанного на токенах, требуется параметр `redirect_uri`, а также прокси-сервер и UserAgent. Значение параметра `redirect_uri` можно найти в ответах на запросы к VK API, которые возвращают captcha.
553
+
554
+ ```ruby
555
+ result = client.vkcaptcha({
556
+ redirect_uri: 'https://id.vk.com/not_robot_captcha?domain=vk.com&session_token=eyJ....HGsc5B4LyvjA&variant=popup&blank=1',
557
+ userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36'
558
+ })
559
+ ```
560
+
561
+ ### Altcha Captcha
562
+ <sup>[Описание метода API](https://2captcha.com/2captcha-api#altchacaptcha)</sup>
563
+
564
+ Используйте этот метод для решения капчи Altcha. В ответ возвращается токен.
565
+
566
+ ```ruby
567
+ result = client.altcha({
568
+ pageurl: 'https://mysite.com/page/with/altcha',
569
+ challenge: '{"algorithm":"SHA-256","challenge":"a4c9d8e7f1b23a6c...","signature":"7b3e2a9d5c8f1046e2d91c3a..."}'
570
+ # или:
571
+ # challenge_url: 'https://example.com/altcha-challenge'
572
+ })
573
+ ```
574
+
575
+ ### Binancecaptcha
576
+
577
+ <sup>[Описание метода API](https://2captcha.com/2captcha-api#binance)</sup>
578
+
579
+ Используйте этот метод для решения капчи Binancecaptcha. В ответ возвращается токен.
580
+
581
+ ```ruby
582
+ result = client.binance({
583
+ sitekey => "login",
584
+ url => "https://example.com/page-with-binance",
585
+ validate_id => "cb0bfef...e54ecd57b"
586
+ })
587
+ ```
588
+
589
+ ### Hunt Captcha
590
+
591
+ <sup>[Описание метода API](https://2captcha.com/2captcha-api#hunt)</sup>
592
+
593
+ Основанный на токенах метод автоматизированного решения Hunt captcha. Использует двухшаговый процесс: первый запрос без `data` возвращает X-HD fingerprint; после отправки его на сайт и получения `meta.token` второй запрос с `data` возвращает финальный токен.
594
+
595
+ > [!IMPORTANT]
596
+ > Для решения Hunt captcha необходимо использовать прокси. Рекомендуется использовать [резидентные прокси].
597
+
598
+ ```ruby
599
+ result = client.hunt({
600
+ pageurl: "https://example.com/page-with-hunt",
601
+ api_get_lib: "https://example.com/hd-api/external/apps/app-id/api.js",
602
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
603
+ proxytype: "http",
604
+ proxy: "proxyuser:strongPassword@123.123.123.123:3128"
605
+ })
606
+ ```
607
+
608
+ ### Tspd
609
+
610
+ <sup>[Описание метода API](https://2captcha.com/2captcha-api#tspd)</sup>
611
+
612
+ Используйте этот метод для решения капчи TSPD. В ответ возвращаются cookies. Прокси обязателен — режима без прокси не существует.
613
+
614
+ > [!IMPORTANT]
615
+ > Для решения TSPD captcha необходимо использовать прокси. Один и тот же IP-адрес должен использоваться на всех этапах: получение cookies, решение задачи и использование результата.
616
+
617
+ ```ruby
618
+ result = client.tspd({
619
+ pageurl: "https://example.com/page-with-tspd",
620
+ tspd_cookie: "TS...",
621
+ html_page_base64: "PGh0bWw+...",
622
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
623
+ proxytype: "http",
624
+ proxy: "proxyuser:strongPassword@123.123.123.123:3128"
625
+ })
626
+ ```
627
+
628
+ ### Basilisk
629
+
630
+ <sup>[Описание метода API](https://2captcha.com/2captcha-api#basilisk)</sup>
631
+
632
+ Основанный на токенах метод автоматизированного решения капчи Basilisk.
633
+
634
+ ```ruby
635
+ result = client.basilisk({
636
+ pageurl: "https://example.com/page-with-basilisk",
637
+ sitekey: "SITE_KEY"
638
+ })
639
+ ```
640
+
641
+ ### Alibaba
642
+
643
+ <sup>[Описание метода API](https://2captcha.com/2captcha-api#alibaba)</sup>
644
+
645
+ Основанный на токенах метод автоматизированного решения капчи Alibaba.
646
+
647
+ ```ruby
648
+ result = client.alibaba({
649
+ pageurl: "https://example.com/page-with-alibaba",
650
+ scene_id: "SCENE_ID",
651
+ prefix: "PREFIX"
652
+ })
653
+ ```
654
+
655
+ ### Yidun
656
+
657
+ <sup>[Описание метода API](https://2captcha.com/2captcha-api#yidun)</sup>
658
+
659
+ Основанный на токенах метод автоматизированного решения капчи Yidun.
660
+
661
+ ```ruby
662
+ result = client.yidun({
663
+ pageurl: "https://example.com/page-with-yidun",
664
+ sitekey: "SITE_KEY"
665
+ })
666
+ ```
667
+
668
+ ### Drag & Drop Captcha
669
+
670
+ <sup>[Описание метода API](https://2captcha.com/2captcha-api#drag-and-drop-captcha)</sup>
671
+
672
+ Используйте этот метод для решения капч, где одну или несколько картинок нужно перетащить на определённые позиции фонового изображения. `body` — фоновое изображение, `images` — массив изображений для перетаскивания, оба в Base64 — файлы нужно прочитать и закодировать самостоятельно, как показано ниже. Порядок `images` важен: в ответе используется тот же порядок.
673
+
674
+ В ответе приходит строка с координатами для каждой картинки из `images`, разделёнными `|`. Если картинку двигать не нужно, для неё возвращается буквальное значение `null`.
675
+
676
+ ```ruby
677
+ result = client.drag_drop({
678
+ body: bodyStr,
679
+ images: [image1Str, image2Str],
680
+ textinstructions: "Drag the images to proper position"
681
+ })
682
+ ```
683
+
684
+ ### Imperva (Incapsula)
685
+
686
+ <sup>[Описание метода API](https://2captcha.com/2captcha-api#imperva)</sup>
687
+
688
+ Основанный на cookies метод автоматизированного решения капчи Imperva (Incapsula). Параметры `incapsula_script_url` и `incapsula_cookies` генерируются динамически и могут отличаться при каждой загрузке страницы. Необязательно можно передать `reese84_url_endpoint`, если он нужен на конкретном сайте, и `userAgent` браузера, с которым открывается страница.
689
+
690
+ В ответе приходят cookies для каждого домена в `request.domains` — их нужно передать на целевой сайт. Если в ответе пришёл `request.headers.User-Agent`, используйте тот же User-Agent в запросах к сайту.
691
+
692
+ > [!IMPORTANT]
693
+ > Для решения Imperva captcha необходимо использовать прокси. Рекомендуется использовать [резидентные прокси].
694
+
695
+ ```ruby
696
+ result = client.imperva({
697
+ pageurl: "https://example.com/page-with-imperva",
698
+ incapsula_script_url: "/_Incapsula_Resource?SWUDNSAI=31&xinfo=1",
699
+ incapsula_cookies: "visid_incap_123456=sample; incap_ses_123_123456=sample",
700
+ reese84_url_endpoint: "https://example.com/_Incapsula_Resource?reese84=1",
701
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
702
+ proxytype: "http",
703
+ proxy: "proxyuser:strongPassword@123.123.123.123:3128"
704
+ })
705
+ ```
479
706
 
480
707
  ## Другие методы
481
708
 
data/api_2captcha.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["info@2captcha.com"]
10
10
 
11
11
  spec.summary = "2Captcha API wrapper for Ruby."
12
- spec.description = "Ruby package for easy integration with the API of 2captcha captcha solving service to bypass recaptcha, hcaptcha, funcaptcha, geetest and solve any other captchas."
12
+ spec.description = "Ruby package for easy integration with the API of 2captcha captcha solving service to bypass recaptcha, funcaptcha, geetest and solve any other captchas."
13
13
  spec.homepage = "https://2captcha.com/"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 2.6.0"
@@ -0,0 +1,16 @@
1
+
2
+ require_relative '../lib/api_2captcha'
3
+
4
+ client = Api2Captcha.new(ARGV[0])
5
+
6
+ begin
7
+ result = client.alibaba({
8
+ pageurl: "https://example.com/page-with-alibaba",
9
+ scene_id: "SCENE_ID",
10
+ prefix: "PREFIX"
11
+ })
12
+ rescue StandardError => e
13
+ puts(e)
14
+ end
15
+
16
+ puts "Result: #{result.inspect}"
@@ -0,0 +1,12 @@
1
+ require 'api_2captcha'
2
+
3
+ client = Api2Captcha.new("YOUR_API_KEY")
4
+
5
+ result = client.altcha({
6
+ pageurl: 'https://mysite.com/page/with/altcha',
7
+ challenge: '{"algorithm":"SHA-256","challenge":"a4c9d8e7f1b23a6c...","signature":"7b3e2a9d5c8f1046e2d91c3a..."}'
8
+ # or:
9
+ # challenge_url: 'https://example.com/altcha-challenge'
10
+ })
11
+
12
+ puts "Result: #{result.inspect}"
@@ -0,0 +1,14 @@
1
+ require 'api_2captcha'
2
+
3
+ client = Api2Captcha.new("YOUR_API_KEY")
4
+
5
+ result = client.amazon_waf({
6
+ sitekey: '0x1AAAAAAAAkg0s2VIOD34y5',
7
+ iv: 'CgAHbCe2GgAAAAAj',
8
+ context: '9BUgmlm48F92WUoqv97a49ZuEJJ50TCk9MVr3C7WMtQ0X6flVbufM4n8mjFLmbLVAPgaQ1Jydeaja94iAS49ljb+sUNLoukWedAQZKrlY4RdbOOzvcFqmD/ZepQFS9N5w15Exr4VwnVq+HIxTsDJwRviElWCdzKDebN/mk8/eX2n7qJi5G3Riq0tdQw9+C4diFZU5E97RSeahejOAAJTDqduqW6uLw9NsjJBkDRBlRjxjn5CaMMo5pYOxYbGrM8Un1JH5DMOLeXbq1xWbC17YSEoM1cRFfTgOoc+VpCe36Ai9Kc=',
9
+ pageurl: 'https://non-existent-example.execute-api.us-east-1.amazonaws.com/latest',
10
+ challenge_script: "https://41bcdd4fb3cb.610cd090.us-east-1.token.awswaf.com/41bcdd4fb3cb/0d21de737ccb/cd77baa6c832/challenge.js",
11
+ captcha_script: "https://41bcdd4fb3cb.610cd090.us-east-1.captcha.awswaf.com/41bcdd4fb3cb/0d21de737ccb/cd77baa6c832/captcha.js"
12
+ })
13
+
14
+ puts "Result: #{result.inspect}"
@@ -0,0 +1,15 @@
1
+
2
+ require_relative '../lib/api_2captcha'
3
+
4
+ client = Api2Captcha.new(ARGV[0])
5
+
6
+ begin
7
+ result = client.basilisk({
8
+ pageurl: "https://example.com/page-with-basilisk",
9
+ sitekey: "SITE_KEY"
10
+ })
11
+ rescue StandardError => e
12
+ puts(e)
13
+ end
14
+
15
+ puts "Result: #{result.inspect}"
@@ -0,0 +1,17 @@
1
+
2
+ require_relative '../lib/api_2captcha'
3
+
4
+ client = Api2Captcha.new(ARGV[0])
5
+
6
+ begin
7
+ result = client.binance({
8
+ sitekey => "login",
9
+ url => "https://example.com/page-with-binance",
10
+ validate_id => "cb0bfef...e54ecd57b"
11
+ })
12
+ rescue StandardError => e
13
+ puts(e)
14
+ end
15
+
16
+
17
+ puts "Result: #{result.inspect}"
@@ -0,0 +1,13 @@
1
+ require 'api_2captcha'
2
+
3
+ client = Api2Captcha.new("YOUR_API_KEY")
4
+
5
+ result = client.canvas({
6
+ image: 'path/to/captcha.jpg',
7
+ previous_id: 0,
8
+ lang: 'en',
9
+ hint_image: 'path/to/hint.jpg',
10
+ hint_text: 'Draw around apple'
11
+ })
12
+
13
+ puts "Result: #{result.inspect}"