-
Notifications
You must be signed in to change notification settings - Fork 4
/
twitter_web_captcha_solver.js
84 lines (73 loc) · 2.27 KB
/
twitter_web_captcha_solver.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const axios = require('axios');
const PAGE_URL = "https://twitter.com"; // Replace with your Website
const CLIENT_KEY = "capsolver.com api key"; // Replace with your CAPSOLVER API Key
const SITE_KEY = "2CB16598-CB82-4CF7-B332-5990DB66F3AB";
const headers = {
"cache-control": "max-age=0",
"sec-ch-ua": '"Not/A)Brand";v="99", "Google Chrome";v="107", "Chromium";v="107"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "Windows",
"upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
"accept": "*/*",
"sec-fetch-site": "same-origin",
"sec-fetch-mode": "navigate",
"sec-fetch-user": "?1",
"sec-fetch-dest": "document",
"accept-encoding": "gzip, deflate, br",
"accept-language": "en,fr-FR;q=0.9,fr;q=0.8,en-US;q=0.7"
};
async function createTask(payload) {
try {
const res = await axios.post('https://api.capsolver.com/createTask', {
clientKey: CLIENT_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: CLIENT_KEY,
taskId: taskId
});
if( res.data.status == "ready") {
success = true;
console.log(res.data)
return res.data;
}
}
} catch (error) {
console.error(error);
return null;
}
}
async function solveFuncaptcha(pageURL, siteKey) {
const taskPayload = {
type: "FunCaptchaTaskProxyless",
websiteURL: pageURL,
websitePublicKey: siteKey,
};
const taskData = await createTask(taskPayload);
return await getTaskResult(taskData.taskId);
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function main() {
try {
const response = await solveFuncaptcha(PAGE_URL, SITE_KEY );
console.log(`Received FunCaptcha Token: ${response.solution.token}`);
}
catch (error) {
console.error(`Error: ${error}`);
}
}
main();