Scraping Google with puppeteer extra plugin recaptcha

John1989

New member
I am using node and puppeteer with plugin for solving recaptcha at Google search results.

It was working like a charm until yesterday. Google reCaptcha is solved but it not redirects to show search result page after solving captcha as it was done before problems started.

I have noticed that now Google reCaptcha is served with frame and puppeteer extra plugin recaptcha potentially can do it as it's said here: https://www.npmjs.com/package/puppeteer-extra-plugin-recaptcha

My code is:
Code:
// puppeteer-extra is a drop-in replacement for puppeteer,
// it augments the installed puppeteer with plugin functionality
const puppeteer = require('puppeteer-extra')

// add recaptcha plugin and provide it your 2captcha token (= their apiKey)
// 2captcha is the builtin solution provider but others would work as well.
// Please note: You need to add funds to your 2captcha account for this to work
const RecaptchaPlugin = require('puppeteer-extra-plugin-recaptcha')
puppeteer.use(
  RecaptchaPlugin({
    provider: {
      id: '2captcha',
      token: 'd4e...' // REPLACE THIS WITH YOUR OWN 2CAPTCHA API KEY ⚡
    },
    visualFeedback: true // colorize reCAPTCHAs (violet = detected, green = solved)
  })
)

// puppeteer usage as normal
puppeteer.launch({ headless: true }).then(async browser => {
  const page = await browser.newPage()
  //await page.goto('https://www.google.com/recaptcha/api2/demo')
  await page.goto('https://www.google.com/search?q=google&oq=google&aqs=chrome..69i57j0l5j69i60l2.735j0j7&sourceid=chrome&ie=UTF-8')

  // That's it, a single line of code to solve reCAPTCHAs 🎉
  await page.solveRecaptchas()

  await Promise.all([
    page.waitForNavigation()
  ])
  let bodyHTML = await page.evaluate(() => document.body.innerHTML);
  console.log(bodyHTML)
  await page.screenshot({ path: 'response.png', fullPage: true })
  await browser.close()
})

and here's the debug:
Code:
seo@serv:~/google$ DEBUG=puppeteer-extra,puppeteer-extra-plugin:* node test.js

  puppeteer-extra-plugin:base:recaptcha Initialized. +0ms
  puppeteer-extra-plugin:recaptcha Initialized {
  visualFeedback: true,
  throwOnError: false,
  provider: { id: '2captcha', token: 'd4e...' }
} +0ms
  puppeteer-extra plugin registered recaptcha +0ms
  puppeteer-extra no dependencies are missing +1ms
  puppeteer-extra orderPlugins:before [ 'recaptcha' ] +0ms
  puppeteer-extra orderPlugins:after [ 'recaptcha' ] +0ms
  puppeteer-extra-plugin:recaptcha onPageCreated about:blank +0ms
  puppeteer-extra-plugin:recaptcha solveRecaptchas +0ms
  puppeteer-extra-plugin:recaptcha findRecaptchas +0ms
  puppeteer-extra-plugin:recaptcha hasRecaptchaScriptTag true +0ms
  puppeteer-extra-plugin:recaptcha waitForRecaptchaClient - start 2020-05-23T22:04:15.081Z +0ms
  puppeteer-extra-plugin:recaptcha waitForRecaptchaClient - end 2020-05-23T22:04:15.091Z +0ms
  puppeteer-extra-plugin:recaptcha _generateContentScript findRecaptchas undefined +0ms
  puppeteer-extra-plugin:recaptcha findRecaptchas {
  captchas: [
    {
      sitekey: '6LfwuyUTAAAAAOAmoS0fdqijC2PbbdH4kjq62Y1b',
      callback: 'submitCallback',
      id: 'oda83noeflau',
      widgetId: 0,
      display: [Object],
      url: 'https://www.google.com/sorry/index?continue=https://www.google.com/search%3Fq%3Dklima%26oq%3Dgoogle%26aqs%3Dchrome..69i57j0l5j69i60l2.735j0j7%26sourceid%3Dchrome%26ie%3DUTF-8&q=EgS8pdi4GN67pvYFIhkA8aeDS9yQqQWq3BMCa6xUSD_F653Fxcx7MgFy',
      hasResponseElement: true
    }
  ],
  error: null
} +0ms
  puppeteer-extra-plugin:recaptcha getRecaptchaSolutions +0ms
  puppeteer-extra-plugin:recaptcha:2captcha Requesting solution.. {
  provider: '2captcha',
  id: 'oda83noeflau',
  requestAt: 2020-05-23T22:04:15.100Z
} +0ms
  puppeteer-extra-plugin:recaptcha:2captcha Got response {
  err: null,
  result: {
    id: '63956086379',
    text: '03AGdBq26iX0JWbJGTu1Bbl98SH2ZQQxAsLELiNrf9Iz14ORUZPvdjRgNPuF2dgpERJb1ylQqQyw4dSDs8K-UruIlaeE8K9c064cCHYOeuwvggqV91bzYkZDbX39NUToTr7UDgO0LOTts803ELdwNxp5FRZutEqpwK4aTjzX9u8ROXJ1-v4ozbJofb38-zVnhm1eftXYpLxllJpXonswmha5GJRPIwPjKv4RZCdz6xTQRN1wtOPX4emUPBj2qadsKpTg633JV46sh2c66vT7Syb4BSFajNFfR_GbbFdPlnDcd5_E4gg3kV58c'
  },
  invalid: [Function: bound ]
} +2s
  puppeteer-extra-plugin:recaptcha getRecaptchaSolutions {
  solutions: [
    {
      provider: '2captcha',
      id: 'oda83noeflau',
      requestAt: 2020-05-23T22:04:15.100Z,
      providerCaptchaId: '63956086379',
      text: '03AGdBq26iX0JWbJGTu1Bbl98SH2ZQQxAsLELiNrf9Iz14ORUZPvdjRgNPuF2dgpERJb1ylQqQyw4dSDs8K-UruIlaeE8K9c064cCHYOeuwvggqV91bzYkZDbX39NUToTr7UDgO0LOTts803ELdwNxp5FRZutEqpwK4aTjzX9u8ROXJ1-v4ozbJofb38-zVnhm1eftXYpLxllJpXonswmha5GJRPIwPjKv4RZCdz6xTQRN1wtOPX4emUPBj2qadsKpTg633JV46sh2c66vT7Syb4BSFajNFfR_GbbFdPlnDcd5_E4gg3kV58c',
      responseAt: 2020-05-23T22:04:17.370Z,
      hasSolution: true,
      duration: 2.27
    }
  ],
  error: undefined
} +0ms
  puppeteer-extra-plugin:recaptcha enterRecaptchaSolutions +0ms
  puppeteer-extra-plugin:recaptcha _generateContentScript enterRecaptchaSolutions {
  solutions: [
    {
      provider: '2captcha',
      id: 'oda83noeflau',
      requestAt: 2020-05-23T22:04:15.100Z,
      providerCaptchaId: '63956086379',
      text: '03AGdBq26iX0JWbJGTu1Bbl98SH2ZQQxAsLELiNrf9Iz14ORUZPvdjRgNPuF2dgpERJb1ylQqQyw4dSDs8K-UruIlaeE8K9c064cCHYOeuwvggqV91bzYkZDbX39NUToTr7UDgO0LOTts803ELdwNxp5FRZutEqpwK4aTjzX9u8ROXJ1-v4ozbJofb38-zVnhm1eftXYpLxllJpXonswmha5GJRPIwPjKv4RZCdz6xTQRN1wtOPX4emUPBj2qadsKpTg633JV46sh2c66vT7Syb4BSFajNFfR_GbbFdPlnDcd5_E4gg3kV58c',
      responseAt: 2020-05-23T22:04:17.370Z,
      hasSolution: true,
      duration: 2.27
    }
  ]
} +0ms
  puppeteer-extra-plugin:recaptcha enterRecaptchaSolutions {
  solved: [
    {
      id: 'oda83noeflau',
      responseElement: true,
      responseCallback: true,
      isSolved: true,
      solvedAt: {}
    }
  ],
  error: undefined
} +0ms
  puppeteer-extra-plugin:recaptcha solveRecaptchas {
  captchas: [
    {
      sitekey: '6LfwuyUTAAAAAOAmoS0fdqijC2PbbdH4kjq62Y1b',
      callback: 'submitCallback',
      id: 'oda83noeflau',
      widgetId: 0,
      display: [Object],
      url: 'https://www.google.com/sorry/index?continue=https://www.google.com/search%3Fq%3Dklima%26oq%3Dgoogle%26aqs%3Dchrome..69i57j0l5j69i60l2.735j0j7%26sourceid%3Dchrome%26ie%3DUTF-8&q=EgS8pdi4GN67pvYFIhkA8aeDS9yQqQWq3BMCa6xUSD_F653Fxcx7MgFy',
      hasResponseElement: true
    }
  ],
  solutions: [
    {
      provider: '2captcha',
      id: 'oda83noeflau',
      requestAt: 2020-05-23T22:04:15.100Z,
      providerCaptchaId: '63956086379',
      text: '03AGdBq26iX0JWbJGTu1Bbl98SH2ZQQxAsLELiNrf9Iz14ORUZPvdjRgNPuF2dgpERJb1ylQqQyw4dSDs8K-UruIlaeE8K9c064cCHYOeuwvggqV91bzYkZDbX39NUToTr7UDgO0LOTts803ELdwNxp5FRZutEqpwK4aTjzX9u8ROXJ1-v4ozbJofb38-zVnhm1eftXYpLxllJpXonswmha5GJRPIwPjKv4RZCdz6xTQRN1wtOPX4emUPBj2qadsKpTg633JV46sh2c66vT7Syb4BSFajNFfR_GbbFdPlnDcd5_E4gg3kV58c',
      responseAt: 2020-05-23T22:04:17.370Z,
      hasSolution: true,
      duration: 2.27
    }
  ],
  solved: [
    {
      id: 'oda83noeflau',
      responseElement: true,
      responseCallback: true,
      isSolved: true,
      solvedAt: {}
    }
  ],
  error: undefined
} +0ms

Captcha is solved but I am not redirected to the Google search results page :(

Tried also with iframe solution, but at the debug it says that hasn't found any captcha.

Code:
// Loop over all potential frames on that page
for (const frame of page.mainFrame().childFrames()) {
  // Attempt to solve any potential reCAPTCHAs in those frames
  await frame.solveRecaptchas()
}

I need help - I don't know node well. Thank you in advance for your help!