Skip to content

Commit

Permalink
added Amazon example
Browse files Browse the repository at this point in the history
  • Loading branch information
billgates007 committed Mar 30, 2023
1 parent ab9e30f commit c2ca263
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ __Requirements:__
- npm packages _puppeteer_ and _@antiadmin/anticaptchaofficial_

__List of solutions:__
- [Bypass](https://github.com/MoterHaker/bypass-captcha-examples/blob/main/amazon.js) Amazon FunCaptcha like [this](https://www.amazon.com/aaut/verify/flex-offers/challenge?challengeType=ARKOSE_LEVEL_1&returnTo=https://www.amazon.com&headerFooter=false) one.
- [Bypass](https://github.com/MoterHaker/bypass-captcha-examples/blob/main/cloudflare.js) CloudFlare with easy filters.
- [Bypass](https://github.com/MoterHaker/bypass-captcha-examples/blob/main/cloudflare_advanced.js) CloudFlare with strong filters (SSL handshake fingerprint).
- [Bypass](https://github.com/MoterHaker/bypass-captcha-examples/blob/main/geo.captcha-delivery.com.js) DataDome protection, [Python version](https://github.com/MoterHaker/bypass-captcha-examples/blob/main/geo.captcha-delivery.py)
Expand Down
110 changes: 110 additions & 0 deletions amazon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
Amazon captcha bypass.
Install dependencies:
npm install puppeteer @antiadmin/anticaptchaofficial
Run in head-on mode:
node amazon.js
* */

const anticaptcha = require("@antiadmin/anticaptchaofficial");
const pup = require('puppeteer');

//Anti-captcha.com API key
const apiKey = 'API_KEY_HERE';

//control address with Funcaptcha
const url = 'https://www.amazon.com/aaut/verify/flex-offers/challenge?challengeType=ARKOSE_LEVEL_1&returnTo=https://www.amazon.com&headerFooter=false';

let browser = null;
let page = null;


(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
}


try {
antigateResult = await anticaptcha.solveAntiGateTask(
url,
'Amazon uniqueValidationId', {});
} catch (e) {
console.error("could not solve captcha: "+e.toString());
return;
}

console.log("Task result:\n", antigateResult);

const fingerPrint = antigateResult.fingerprint;

try {
console.log('opening browser ..');


let options = {
headless: false,
ignoreHTTPSErrors: true,
devtools: true,
args: [
'--window-size='+fingerPrint['self.screen.width']+','+fingerPrint['self.screen.height']
]
};
browser = await pup.launch(options);

console.log('creating new page ..');
page = await browser.newPage();
} catch (e) {
console.log("could not open browser: "+e);
return false;
}

//screen size
console.log('setting view port to '+fingerPrint['self.screen.width']+'x'+fingerPrint['self.screen.height']);
await page.setViewport({width: fingerPrint['self.screen.width'], height: fingerPrint['self.screen.height']});

//user agent
let userAgent = '';
if (fingerPrint['self.navigator.userAgent']) {
userAgent = fingerPrint['self.navigator.userAgent'];
} else {
if (fingerPrint['self.navigator.appVersion'] && fingerPrint['self.navigator.appCodeName']) {
userAgent = fingerPrint['self.navigator.appCodeName'] + '/' + fingerPrint['self.navigator.appVersion']
}
}
console.log('setting browser user agent to '+userAgent);
await page.setUserAgent(userAgent);

console.log('setting cookies');
let cookies = [];
for (const name in antigateResult.cookies) {
cookies.push({ name: name, value: antigateResult.cookies[name], domain: antigateResult.domain })
}
await page.setCookie(...cookies);


try {
await page.goto(antigateResult.url, {
waitUntil: "networkidle0"
});
} catch (e) {
console.log('err while loading the page: '+e);
}


console.log('done');



})();

0 comments on commit c2ca263

Please sign in to comment.