Solving Audio Captcha using Puppeteer and 2Captcha

69 Views Asked by At

I'm trying to read the audio captcha but am unable to read it. It's showing me undefined.

const puppeteer = require('puppeteer');
const request = require('request');
const fs = require('fs');

(async () => {
  const browser = await puppeteer.launch({
    headless: true,
  });

  const audioFilePath = 'D:\\amazon_reviews\\audio.mp3';

  const audioBuffer = fs.readFileSync(audioFilePath);
  const base64Data = audioBuffer.toString('base64');

  request.post({
    url: 'http://2captcha.com/in.php',
    formData: {
      key: 'my_key',
      body: base64Data,
    }
  }, async (error, response, body) => {
    if (error) {
      console.error(error);
    } else {
      console.log(body)
      const captchaId = body.split('|')[1];
      request.get({
        url: `http://2captcha.com/res.php?key=my_key&action=get&id=${captchaId}`
      }, async (error, response, body) => {
        if (error) {
          console.error(error);
        } else {
          const captchaText = body.split('|')[1];
         

I don't to how to deal with this. I am try to integrate puppeteer and 2captcha but getting undefined. It is unable to read the audio.mp3 file.

0

There are 0 best solutions below