-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimplesNacional.js
62 lines (56 loc) · 1.61 KB
/
SimplesNacional.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
53
54
55
56
57
58
59
60
61
62
const axios = require('axios');
const CAPSOLVER_API_KEY = "your capsolver.com api key";
let PROXY = "";
function sleep(ms){
return new Promise(resolve => setTimeout(resolve, ms));
}
async function createTask(payload){
try{
const res = await axios.post('https://api.capsolver.com/createTask', {
clientKey: CAPSOLVER_API_KEY,
task: payload
});
return res.data;
}catch(error){
console.error(error);
}
}
async function getTaskResult(taskId){
try{
success = false;
while(success == false){
await sleep(1000);
console.log("Getting task result for task ID:" + taskId);
const res = await axios.post('https://api.capsolver.com/getTaskResult', {
clientKey: CAPSOLVER_API_KEY,
taskId: taskId
});
if( res.data.status == "ready") {
success = true;
console.log(res.data)
return res.data;
}
}
}catch(error){
console.error(error);
}
}
async function solveHcaptcha(){
const taskPayload = {
type: "HCaptchaTask",
websiteURL: "https://www.nfe.fazenda.gov.br",
websiteKey: "38604819-bb1e-4105-b3bf-49c1ffdf9475",
"proxy": PROXY
};
const taskData = await createTask(taskPayload);
return getTaskResult(taskData.taskId);
}
async function main(){
try{
const response = await solveHcaptcha();
console.log(`Received token: ${response.solution.gRecaptchaResponse}`);
}catch(error){
console.error(error);
}
}
main();