How to solve AWS Captcha using Puppeteer and Capsolver Extension
1. Installing puppeteer components
⚠️In this blog, will explain how to setup puppeteer js with capsolver extension for solve aws captcha. But you can apply this for all the captchas.
npm i puppeteer puppeteer-extra puppeteer-extra-plugin-stealth
2. Setting up the extension
Download the archive with the extension, and unzip it to the folder ./CapSolver.Browser.Extension in the root of the project.
The extension has many settings, including automatic solution of the specified type of captcha, support for proxy, and other settings. The settings are available in the file ./assets/config.json.
These settings are:
{
"apiKey": "",
"appId": "",
"useCapsolver": true,
"manualSolving": false,
"solvedCallback": "captchaSolvedCallback",
"useProxy": false,
"proxyType": "http",
"hostOrIp": "",
"port": "",
"proxyLogin": "",
"proxyPassword": "",
"enabledForBlacklistControl": false,
"blackUrlList": [],
"enabledForRecaptcha": true,
"enabledForRecaptchaV3": true,
"enabledForHCaptcha": true,
"enabledForFunCaptcha": true,
"enabledForImageToText": true,
"enabledForAwsCaptcha": true,
"reCaptchaMode": "click",
"hCaptchaMode": "click",
"reCaptchaDelayTime": 0,
"hCaptchaDelayTime": 0,
"textCaptchaDelayTime": 0,
"awsDelayTime": 0,
"reCaptchaRepeatTimes": 10,
"reCaptcha3RepeatTimes": 10,
"hCaptchaRepeatTimes": 10,
"funCaptchaRepeatTimes": 10,
"textCaptchaRepeatTimes": 10,
"awsRepeatTimes": 10,
"textCaptchaSourceAttribute": "capsolver-image-to-text-source",
"textCaptchaResultAttribute": "capsolver-image-to-text-result"
}
Enter your API key in the extension settings file ./assets/config.json. Your key must be written to the value of the apiKey field. You can see and copy you're API key on the page.
Be sure enabledForAwsCaptcha is true
Example: apiKey: "CAP-4FDBD3SDFSD-23S-2-3"
3. Setting up Puppeter for solve aws captcha with Capsolver Extension
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
const { executablePath } = require('puppeteer');
(async () => {
const pathToExtension = require('path').join(__dirname, 'CapSolver.Browser.Extension');
puppeteer.use(StealthPlugin())
const browser = await puppeteer.launch({
headless: false,
args: [
`--disable-extensions-except=${pathToExtension}`,
`--load-extension=${pathToExtension}`,
],
executablePath: executablePath()
});
const [page] = await browser.pages()
})();
Next, is opening the page example page, and sending the captcha to capsolver.
Using page.goto() we go to the page with the aws captcha. Next, you need to send a captcha for a solution, this can be done manually or automatically.
In our example, we will send a captcha manually, for this we wait until the extension button with the CSS selector #aws-anchor-label is available, then click on this button. After clicking on the button, the captcha will go to the service for a solution.
await page.goto('https://site.example')
// Waiting for the element with the CSS selector ".captcha-solver" to be available
await page.waitForSelector('#aws-anchor-label')
// Click on the element with the specified selector
await page.click('#aws-anchor-label')
Full Code:
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
const { executablePath } = require('puppeteer');
(async () => {
const pathToExtension = require('path').join(__dirname, 'CapSolver.Browser.Extension');
puppeteer.use(StealthPlugin())
const browser = await puppeteer.launch({
headless: false,
args: [
`--disable-extensions-except=${pathToExtension}`,
`--load-extension=${pathToExtension}`,
],
executablePath: executablePath()
});
const [page] = await browser.pages()
// Opening a page
await page.goto('https://site.example')
// Waiting for the element with the CSS selector "#aws-anchor-label" to be available
await page.waitForSelector('#aws-anchor-label')
// Click on the element with the specified selector
})();
And that is! You solved aws captcha using Capsolver Extension and Puppeteer. If you need to solve other captchas, you just need to replicate the tutorial for the other captchas.