-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathgeo.captcha-delivery.com.js
93 lines (73 loc) · 2.84 KB
/
geo.captcha-delivery.com.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
85
86
87
88
89
90
91
92
93
/*
Datadome bypass with AntiGate template.
Install dependencies:
npm install @antiadmin/anticaptchaofficial axios https-proxy-agent
* */
const axios = require("axios");
const httpsProxyAgent = require('https-proxy-agent');
const anticaptcha = require("@antiadmin/anticaptchaofficial");
//address behind datadome
const checkUrl = 'https://www.allopneus.com/liste/pneu-auto?saison%5B%5D=4seasons&saison%5B%5D=ete&saison%5B%5D=hiver&page=1';
//Anti-captcha.com API key
const apiKey = 'API_KEY_HERE';
// STOP! IMPORTANT! Shared proxy services won't work!
// Use ONLY self-installed proxies on your own infrastructure! Instruction: https://anti-captcha.com/apidoc/articles/how-to-install-squid
// Again and again people people insist they have best purchased proxies. NO YOU DO NOT!
// Absolutely recommended to read this FAQ about proxies: https://anti-captcha.com/faq/510_questions_about_solving_recaptcha_with_proxy__applies_to_funcaptcha__geetest__hcaptcha_
const proxyAddress = '11.22.33.44';
const proxyPort = 1234;
const proxyLogin = 'login';
const proxyPassword = 'pass';
const proxyString = `http://${proxyLogin}:${proxyPassword}@${proxyAddress}:${proxyPort}`;
const agent = new httpsProxyAgent(proxyString);
(async () => {
anticaptcha.setAPIKey(apiKey);
const balance = await anticaptcha.getBalance();
if (balance <= 0) {
console.log('Topup your anti-captcha.com balance!');
return;
} else {
console.log('API key balance is '+balance+', continuing');
// anticaptcha.shutUp(); //uncomment for silent captcha recognition
}
let antigateResult = null;
try {
antigateResult = await anticaptcha.solveAntiBotCookieTask(
checkUrl,
proxyAddress,
proxyPort,
proxyLogin,
proxyPassword);
} catch (e) {
console.error("could not solve captcha: "+e.toString());
return;
}
const fingerPrint = antigateResult.fingerprint;
const targetCookies = joinCookies(antigateResult.cookies);
console.log(`joined cookies: ${targetCookies}`);
console.log(`user-agent: ${fingerPrint['self.navigator.userAgent']}`);
try {
let responseText = await axios.request({
url: checkUrl,
httpsAgent: agent,
headers: {
'User-Agent': fingerPrint['self.navigator.userAgent'],
'Cookie': targetCookies,
'Accept-Encoding': 'deflate',
'Accept': 'text/html',
'Accept-Language': 'en'
}
});
console.log(responseText.data);
} catch (e) {
console.error('Could not request page')
console.log(e.toString());
}
})();
function joinCookies(object) {
let resultArray = [];
for (const key in object) {
resultArray.push(key+"="+object[key])
}
return resultArray.join("; ");
}