Skip to content

Commit 9dfe287

Browse files
Merge pull request #18 from 2captcha/RC-2942
RC-2942 Add methods
2 parents 6c3631f + 5a2ec5c commit 9dfe287

19 files changed

+918
-79
lines changed

README.md

+183-8
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010
# JavaScript module for 2Captcha API (captcha solver)
1111

12-
The easiest way to quickly integrate the [2Captcha](https://2captcha.com/) captcha-solving service into your code and automate the solving of any type of captcha.
13-
Examples of API requests for different captcha types are available on the [JavaScript captcha solver](https://2captcha.com/lang/javascript) page.
12+
The easiest way to quickly integrate the [2Captcha] captcha-solving service into your code and automate the solving of any type of captcha.
13+
Examples of API requests for different captcha types are available on the [JavaScript captcha solver] page.
1414

1515
- [JavaScript module for 2Captcha API (captcha solver)](#javascript-module-for-2captcha-api-captcha-solver)
1616
- [Installation](#installation)
1717
- [Configuration](#configuration)
1818
- [TwoCaptcha instance options](#twocaptcha-instance-options)
1919
- [Solve captcha](#solve-captcha)
20-
- [Image captchas](#image-captcha)
20+
- [Image Captcha](#image-captcha)
2121
- [reCAPTCHA v2](#recaptcha-v2)
2222
- [reCAPTCHA v3](#recaptcha-v3)
2323
- [hCaptcha](#hcaptcha)
@@ -36,16 +36,26 @@ Examples of API requests for different captcha types are available on the [JavaS
3636
- [Friendly Captcha](#friendly-captcha)
3737
- [Bounding Box Method](#bounding-box-method)
3838
- [Grid](#grid)
39+
- [Text Captcha](#text-captcha)
40+
- [Canvas](#canvas)
41+
- [Rotate](#rotate)
42+
- [KeyCaptcha](#keycaptcha)
43+
- [Cutcaptcha](#cutcaptcha)
44+
- [Tencent](#tencent)
45+
- [atbCAPTCHA](#atbcaptcha)
46+
- [Audio Captcha](#audio-captcha)
3947
- [Other methods](#other-methods)
4048
- [goodReport](#goodreport)
4149
- [badReport](#badreport)
4250
- [balance](#balance)
4351
- [Proxies](#proxies)
4452
- [Examples](#examples)
4553
- [Examples using Puppeteer](#examples-using-puppeteer)
46-
- [Useful articles](#useful-articles)
54+
- [Useful articles](#useful-articles)
4755
- [Get in touch](#get-in-touch)
4856
- [Join the team 👪](#join-the-team-)
57+
- [License](#license)
58+
- [Graphics and Trademarks](#graphics-and-trademarks)
4959

5060

5161
## Installation
@@ -109,7 +119,6 @@ Below you can find basic examples for every captcha type, check out the code bel
109119
To bypass a normal captcha (distorted text on an image) use the following method. This method can also be used to recognize any text in an image.
110120

111121
```js
112-
// Read from a file as base64 text
113122
const imageBase64 = fs.readFileSync("./examples/media/imageCaptcha_6e584.png", "base64")
114123

115124
solver.imageCaptcha({
@@ -119,7 +128,6 @@ solver.imageCaptcha({
119128
max_len: 5
120129
})
121130
.then((res) => {
122-
// Logs the image text
123131
console.log(res);
124132
})
125133
.catch((err) => {
@@ -498,6 +506,164 @@ solver.grid({
498506
})
499507
```
500508

509+
### Text Captcha
510+
511+
<sup>[API method description.](https://2captcha.com/2captcha-api#solving_text_captcha)</sup>
512+
513+
This method can be used to bypass a captcha that requires answering a question provided in clear text.
514+
515+
```js
516+
solver.textCaptcha({
517+
textcaptcha: "If tomorrow is Saturday, what day is today?",
518+
lang: 'en'
519+
})
520+
.then((res) => {
521+
console.log(res);
522+
})
523+
.catch((err) => {
524+
console.log(err);
525+
})
526+
```
527+
528+
### Canvas
529+
530+
<sup>[API method description.](https://2captcha.com/2captcha-api#canvas)</sup>
531+
532+
The canvas method can be used when you need to draw a line around an object on an image. Returns a set of points' coordinates to draw a polygon.
533+
534+
```js
535+
solver.canvas({
536+
body: 'iVBORw0KGgoAAAANSgAAAcIA...',
537+
imginstructions: '/9j/4AAQSkZJRgABAQEA...',
538+
textinstructions: 'Highlight the red CIRCLE'
539+
})
540+
.then((res) => {
541+
console.log(res);
542+
})
543+
.catch((err) => {
544+
console.log(err);
545+
})
546+
```
547+
548+
### Rotate
549+
550+
<sup>[API method description.](https://2captcha.com/2captcha-api#solving_rotatecaptcha)</sup>
551+
552+
This method can be used to solve a captcha that asks to rotate an object. It is mostly used to bypass FunCaptcha. Returns the rotation angle.
553+
554+
```js
555+
solver.rotate({
556+
body: imageBase64,
557+
textinstructions: "Rotate the object to the correct position"
558+
})
559+
.then((res) => {
560+
console.log(res);
561+
})
562+
.catch((err) => {
563+
console.log(err);
564+
})
565+
```
566+
567+
### KeyCaptcha
568+
569+
<sup>[API method description.](https://2captcha.com/2captcha-api#solving_keycaptcha)</sup>
570+
571+
Token-based method to solve KeyCaptcha.
572+
573+
```js
574+
solver.keyCaptcha({
575+
pageurl: "https://2captcha.com/demo/keycaptcha",
576+
userId: '184015',
577+
sessionId: '0917788cad24ad3a69813c4fcd556061',
578+
webServerSign: '02f7f9669f1269595c4c69bcd4a3c52e',
579+
webServerSign2: 'd888700f6f324ec0f32b44c32c50bde1'
580+
})
581+
.then((res) => {
582+
console.log(res);
583+
})
584+
.catch((err) => {
585+
console.log(err);
586+
})
587+
```
588+
589+
### Cutcaptcha
590+
591+
<sup>[API method description.](https://2captcha.com/2captcha-api#cutcaptcha)</sup>
592+
593+
Use this method to solve Cutcaptcha. Returns the response in JSON.
594+
595+
```js
596+
solver.cutCaptcha({
597+
pageurl: "https://mysite.com/page/with/cutcaptcha",
598+
misery_key: "098e6a849af406142e3150dbf4e6d0538db2b51f",
599+
api_key: "SAs61IAI",
600+
})
601+
.then((res) => {
602+
console.log(res);
603+
})
604+
.catch((err) => {
605+
console.log(err);
606+
})
607+
```
608+
609+
### Tencent
610+
611+
<sup>[API method description.](https://2captcha.com/2captcha-api#tencent)</sup>
612+
613+
Use this method to solve Tencent captcha. Returns the response in JSON.
614+
615+
```js
616+
solver.tencent({
617+
pageurl: "https://mysite.com/page/with/tencent",
618+
appId: "189956587"
619+
})
620+
.then((res) => {
621+
console.log(res);
622+
})
623+
.catch((err) => {
624+
console.log(err);
625+
})
626+
```
627+
628+
### atbCAPTCHA
629+
630+
<sup>[API method description.](https://2captcha.com/2captcha-api#atb-captcha)</sup>
631+
632+
Use this method to solve atbCAPTCHA challenge. Returns a token to bypass the captcha.
633+
634+
```js
635+
solver.atbCaptcha({
636+
pageurl: "https://mysite.com/page/with/atbCAPTCHA",
637+
appId: "af25e409b33d722a95e56a230ff8771c",
638+
apiServer: "https://cap.aisecurius.com"
639+
})
640+
.then((res) => {
641+
console.log(res);
642+
})
643+
.catch((err) => {
644+
console.log(err);
645+
})
646+
```
647+
648+
### Audio Captcha
649+
650+
<sup>[API method description.](https://2captcha.com/2captcha-api#audio-recognition)</sup>
651+
652+
Use the following method to bypass an audio captcha (`mp3` formats only). You must provide the language as `lang = 'en'`. Supported languages are "en", "ru", "de", "el", "pt", "fr".
653+
654+
```js
655+
solver.audio({
656+
body: "SUQzBAAAAAAAHFRTU0UAAAA...",
657+
lang: "en"
658+
})
659+
.then((res) => {
660+
console.log(res);
661+
})
662+
.catch((err) => {
663+
console.log(err);
664+
})
665+
```
666+
501667
## Other methods
502668

503669
### goodReport
@@ -558,15 +724,14 @@ At the moment we have implemented examples of bypassing Cloudflare Challenge pag
558724
Links:
559725
- [Cloudflare Bypassing Demo using Puppeteer](https://github.com/2captcha/cloudflare-demo)
560726
- [Solving reCAPTCHA V2 using Puppeteer and clicks](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks)
727+
- [Custom Slider Captcha Demo](https://github.com/2captcha/custom-slider-demo)
561728

562729

563730
## Useful articles
564731
* [How to bypass captcha using JavaScript](https://2captcha.com/blog/how-to-use-javascript-to-bypass-captcha#how-to-solve-and-bypass-a-captcha-with-javascript-using-npm-package-2captchacaptcha-solver)
565732
* [Bypassing Cloudflare Challenge with Puppeteer and 2Captcha](https://2captcha.com/blog/bypassing-cloudflare-challenge-with-puppeteer-and-2captcha)
566733
* [How to bypass Geetest v4 CAPTCHA](https://2captcha.com/blog/geetest-v4-support)
567734
* [Automatic reCAPTCHA V3 resolution - a tutorial for developers and customers](https://2captcha.com/blog/recaptcha-v3-automatic-resolution)
568-
* [Custom Slider Captcha Demo](https://github.com/2captcha/custom-slider-demo)
569-
* [Cloudflare Challenge page bypass code example](https://github.com/2captcha/cloudflare-demo)
570735

571736
## Get in touch
572737

@@ -579,7 +744,17 @@ There are many ways to contribute, of which development is only one! Find your n
579744

580745
<a href="mailto:[email protected]"><img src="https://github.com/user-attachments/assets/36d23ef5-7866-4841-8e17-261cc8a4e033" width="80" height="30"></a>
581746

747+
## License
748+
749+
The code in this repository is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.
750+
751+
### Graphics and Trademarks
752+
753+
The graphics and trademarks included in this repository are not covered by the MIT License. Please contact <a href="mailto:[email protected]">support</a> for permissions regarding the use of these materials.
754+
582755
<!-- Shared links -->
756+
[2Captcha]: https://2captcha.com/
757+
[JavaScript captcha solver]: https://2captcha.com/lang/javascript
583758
[post options]: https://2captcha.com/2captcha-api#normal_post
584759
[list of supported languages]: https://2captcha.com/2captcha-api#language
585760
[Buy residential proxies]: https://2captcha.com/proxy/residential-proxies

examples/atbcaptcha.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const TwoCaptcha = require("../dist/index.js");
2+
require('dotenv').config();
3+
const APIKEY = process.env.APIKEY
4+
const solver = new TwoCaptcha.Solver(APIKEY);
5+
6+
solver.atbCaptcha({
7+
pageurl: "https://mysite.com/page/with/atbCAPTCHA",
8+
appId: "af25e409b33d722a95e56a230ff8771c",
9+
apiServer: "https://cap.aisecurius.com"
10+
})
11+
.then((res) => {
12+
console.log(res);
13+
})
14+
.catch((err) => {
15+
console.log(err);
16+
})

examples/audio.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const TwoCaptcha = require("../dist/index.js");
2+
require('dotenv').config();
3+
const APIKEY = process.env.APIKEY
4+
const solver = new TwoCaptcha.Solver(APIKEY);
5+
const fs = require('fs')
6+
const audioCaptchaBase64 = fs.readFileSync("./media/example.mp3", "base64")
7+
8+
solver.audio({
9+
body: audioCaptchaBase64,
10+
lang: 'en'
11+
})
12+
.then((res) => {
13+
console.log(res);
14+
})
15+
.catch((err) => {
16+
console.log(err);
17+
})

examples/canvas.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const TwoCaptcha = require("../dist/index.js");
2+
require('dotenv').config();
3+
const APIKEY = process.env.APIKEY
4+
const solver = new TwoCaptcha.Solver(APIKEY);
5+
const fs = require('fs')
6+
const imageBase64 = fs.readFileSync("./media/canvas.png", "base64")
7+
const imginstructionsBase64 = fs.readFileSync("./media/canvasImgInstructions.jpg", "base64")
8+
9+
solver.canvas({
10+
body: imageBase64,
11+
textinstructions: 'Highlight the red CIRCLE',
12+
imginstructions: imginstructionsBase64,
13+
})
14+
.then((res) => {
15+
console.log(res);
16+
})
17+
.catch((err) => {
18+
console.log(err);
19+
})

examples/cutcaptcha.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const TwoCaptcha = require("../dist/index.js");
2+
require('dotenv').config();
3+
const APIKEY = process.env.APIKEY
4+
const solver = new TwoCaptcha.Solver(APIKEY);
5+
6+
solver.cutCaptcha({
7+
pageurl: "https://mysite.com/page/with/cutcaptcha",
8+
miseryKey: "098e6a849af406142e3150dbf4e6d0538db2b51f",
9+
apiKey: "SAs61IAI",
10+
})
11+
.then((res) => {
12+
console.log(res);
13+
})
14+
.catch((err) => {
15+
console.log(err);
16+
})

examples/grid.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ require('dotenv').config();
33
const APIKEY = process.env.APIKEY
44
const solver = new TwoCaptcha.Solver(APIKEY);
55
const fs = require('fs')
6-
const imageBase64 = fs.readFileSync("./media/recaptchaGrid3x3.jpg", "base64")
6+
const imageBase64 = fs.readFileSync("./media/recaptchaGrid4x4.jpg", "base64")
7+
const instructionsImageBase64 = fs.readFileSync("./media/recaptchaGridImginstructions4x4.jpg", "base64")
78

89
solver.grid({
910
body: imageBase64,
10-
textinstructions: "Select cars in the image"
11+
textinstructions: "Select all squares with stairs",
12+
imginstructions: instructionsImageBase64,
13+
cols: 4,
14+
rows: 4
1115
})
1216
.then((res) => {
1317
console.log(res);

examples/grid_options.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ const imageInstructionsBase64 = fs.readFileSync("./media/recaptchaGridImginstruc
88

99
solver.grid({
1010
body: imageBase64,
11-
textinstructions: "Select all squares with stairs",
11+
textinstructions: "select all squares with stairs if there are none, click skip",
1212
imginstructions: imageInstructionsBase64,
1313
cols: 4,
1414
rows: 4,
1515
minClicks: 2,
1616
maxClicks: 6,
1717
lang: "en",
1818
canSkip: 1,
19+
imgType: "recaptcha" /* More information about the `img_type` parameter can be found at: https://2captcha.com/2captcha-api#grid */
1920
// pingback: '123.123.123.123' /* More info about pingback https://2captcha.com/setting/pingback */
2021
// previousId: '123456789'
2122
})
@@ -24,4 +25,4 @@ solver.grid({
2425
})
2526
.catch((err) => {
2627
console.log(err);
27-
});
28+
});

0 commit comments

Comments
 (0)