forked from dzmitry-duboyski/2captcha-ts
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from 2captcha/RC-2646
RC-2646 Add Grid method
- Loading branch information
Showing
12 changed files
with
226 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const TwoCaptcha = require("../dist/index.js"); | ||
require('dotenv').config(); | ||
const APIKEY = process.env.APIKEY | ||
const solver = new TwoCaptcha.Solver(APIKEY); | ||
const fs = require('fs') | ||
const imageBase64 = fs.readFileSync("./media/recaptchaGrid3x3.jpg", "base64") | ||
|
||
solver.grid({ | ||
body: imageBase64, | ||
textinstructions: "Select cars in the image" | ||
}) | ||
.then((res) => { | ||
console.log(res); | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const TwoCaptcha = require("../dist/index.js"); | ||
require("dotenv").config(); | ||
const APIKEY = process.env.APIKEY; | ||
const solver = new TwoCaptcha.Solver(APIKEY); | ||
const fs = require("fs"); | ||
const imageBase64 = fs.readFileSync("./media/recaptchaGrid4x4.jpg", "base64"); | ||
const imageInstructionsBase64 = fs.readFileSync("./media/recaptchaGridImginstructions4x4.jpg", "base64"); | ||
|
||
solver.grid({ | ||
body: imageBase64, | ||
textinstructions: "Select all squares with stairs", | ||
imginstructions: imageInstructionsBase64, | ||
cols: 4, | ||
rows: 4, | ||
minClicks: 2, | ||
maxClicks: 6, | ||
lang: "en", | ||
canSkip: 1, | ||
// pingback: '123.123.123.123' /* More info about pingback https://2captcha.com/setting/pingback */ | ||
// previousId: '123456789' | ||
}) | ||
.then((res) => { | ||
console.log(res); | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* | ||
* ### Renaming captcha parameters | ||
* | ||
* Description: parameter names used in the API may differ from those used in the library, in such cases parameter names are renamed in accordance with those used in the API. | ||
* | ||
* @param params - captcha parameters as an object | ||
* @returns returns new object with renamed params | ||
* | ||
*/ | ||
export default function renameParams(params: any) { | ||
let newParams: any = new Object(); | ||
|
||
/** | ||
* Captcha parameters that need to be renamed before sent to the API. | ||
*/ | ||
const replaceParams: any = { | ||
"cols" : "recaptchacols", | ||
"rows" : "recaptcharows", | ||
"minClicks" : "min_clicks", | ||
"maxClicks" : "max_clicks", | ||
"canSkip" : "can_no_answer", | ||
"previousId" : "previousID" | ||
} | ||
|
||
for(let key in params) { | ||
if(replaceParams.hasOwnProperty(key)) { | ||
newParams[replaceParams[key]] = params[key] | ||
} else { | ||
newParams[key] = params[key] | ||
} | ||
} | ||
|
||
return newParams | ||
} |