In this example, you can see how automate an image-based captcha solution in JavaScript using Puppeteer and the 2captcha service. Puppeteer is Node.js library using for automation. 2captcha is service used to solve the captcha.
Set your API KEY
in the file ./index.js#L3
APIKEY=yourApiKey
npm i
npm run start
const getCaptchaAnswer = async () => {
try {
//send captcha
const base64Captcha = fs.readFileSync("./image_captcha.png", "base64");
const res = await solver.imageCaptcha({
body: base64Captcha,
});
return res.data;
} catch (err) {
console.log(err);
}
};
Screenshot: