-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreports.js
More file actions
36 lines (32 loc) · 972 Bytes
/
reports.js
File metadata and controls
36 lines (32 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require('dotenv').config({ path: '../.env' });
const { Solver } = require('../dist/index.js');
const APIKEY = process.env.SOLVECAPTCHA_APIKEY;
const solver = new Solver(APIKEY);
const fs = require('fs')
const imageBase64 = fs.readFileSync("./media/imageCaptcha_6e584.png", "base64")
/**
* Example of solving a base64 image captcha and sending a report based on the result
*/
solver.imageCaptcha({
body: imageBase64,
numeric: 4,
min_len: 5,
max_len: 5,
lang: 'en',
textinstructions: 'Type text on the image'
})
.then((res) => {
console.log(res);
let isCorrectAnswer = res.data === '6e584';
console.log("Is correct answer: " + isCorrectAnswer);
if (isCorrectAnswer) {
console.log("Good report:");
return solver.goodReport(res.id);
} else {
console.log("Bad report:");
return solver.badReport(res.id);
}
})
.catch((err) => {
console.log(err);
})