-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathanticaptcha.js
52 lines (44 loc) · 1.48 KB
/
anticaptcha.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { config } from "./config.js";
import axios from "axios";
import { timeout } from "./index.js";
export async function solveCaptcha() {
console.log('Starting to solve captcha');
let res = await axios(`https://api.anti-captcha.com/createTask`, {
method: "POST",
data: {
"clientKey": config.anticaptchaApikey,
"task": {
"type": "HCaptchaTaskProxyless",
"websiteURL": 'https://app.seinetwork.io',
"websiteKey": "73ec4927-b43f-40b1-b61a-646a5ec58a45",
"isInvisible": false
},
"softId": 0
}
})
await timeout(10000)
let solution = await getCaptchaResponse(res.data.taskId)
return solution
}
async function getCaptchaResponse(taskid) {
let solution = '';
while (!solution) {
let res = await axios(`https://api.anti-captcha.com/getTaskResult`, {
method: 'POST',
data: {
"clientKey": config.anticaptchaApikey,
"taskId": taskid
}
})
if (res?.data.status == "ready") {
console.log(`Captcha status: ${res?.data?.status}`);
return res.data.solution.gRecaptchaResponse
} else if (res?.data?.status == "processing") {
console.log(`Captcha status: ${res?.data?.status}`);
await timeout(5000)
} else {
console.log(res?.data?.errorDescription);
return false
}
}
}