berstend / puppeteer-extra

πŸ’― Teach puppeteer new tricks through plugins.
https://extra.community
MIT License
6.49k stars 742 forks source link

Blank Screen when using puppeteer-extra-plugin-recaptcha #82

Closed e-moshaya closed 4 years ago

e-moshaya commented 4 years ago

When I go to the following link in puppeteer headless session: https://www.gumtree.com/p/vans/mercedes-sprinter-313-cdi-lwb..-fridge-chiller-van..-%C2%A33495..-no-vat..-fsh..-07989464646..-1-owner-/1350359649

I get the following:

image

just using the puppeteer-extra-plugin-recaptcha plugin alone with solveRecaptchas did not bypass the captcha screen.

However, when I use both puppeteer-extra-plugin-recaptcha and puppeteer-extra-plugin-stealth plugins, it seems to bypass the captcha page but only a blank white page is printed. Any ideas?

// 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: 'XXXXXXX' },
    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.gumtree.com/p/vans/mercedes-sprinter-313-cdi-lwb..-fridge-chiller-van..-%C2%A33495..-no-vat..-fsh..-07989464646..-1-owner-/1350359649')

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

  // await Promise.all([
  //   page.waitForNavigation(),
  //   page.click(`#recaptcha-demo-submit`)
  // ])
  await page.screenshot({ path: 'response.png', fullPage: true })
  await browser.close()
})
berstend commented 4 years ago

Could you run your script with debug output enabled and paste that here?

DEBUG=puppeteer-extra,puppeteer-extra-plugin:* node myscript.js
e-moshaya commented 4 years ago

@berstend debug output below:

  puppeteer-extra-plugin:base:anonymize-ua Initialized. +0ms
  puppeteer-extra plugin registered anonymize-ua +0ms
  puppeteer-extra-plugin:base:recaptcha Initialized. +0ms
  puppeteer-extra-plugin:recaptcha Initialized { visualFeedback: true,
  throwOnError: false,
  provider: { id: '2captcha', token: '' } } +0ms
  puppeteer-extra plugin registered recaptcha +3ms
  puppeteer-extra-plugin:base:stealth Initialized. +0ms
  puppeteer-extra plugin registered stealth +1ms
  puppeteer-extra dependencies missing Set {
  'stealth/evasions/chrome.runtime',
  'stealth/evasions/console.debug',
  'stealth/evasions/navigator.languages',
  'stealth/evasions/navigator.permissions',
  'stealth/evasions/navigator.webdriver',
  'stealth/evasions/navigator.plugins',
  'stealth/evasions/window.outerdimensions',
  'stealth/evasions/webgl.vendor',
  'stealth/evasions/user-agent' } +2ms
  puppeteer-extra-plugin:base:stealth/evasions/chrome.runtime Initialized. +0ms
  puppeteer-extra plugin registered stealth/evasions/chrome.runtime +2ms
  puppeteer-extra-plugin:base:stealth/evasions/console.debug Initialized. +0ms
  puppeteer-extra plugin registered stealth/evasions/console.debug +2ms
  puppeteer-extra-plugin:base:stealth/evasions/navigator.languages Initialized. +0ms
  puppeteer-extra plugin registered stealth/evasions/navigator.languages +1ms
  puppeteer-extra-plugin:base:stealth/evasions/navigator.permissions Initialized. +0ms
  puppeteer-extra plugin registered stealth/evasions/navigator.permissions +2ms
  puppeteer-extra-plugin:base:stealth/evasions/navigator.webdriver Initialized. +0ms
  puppeteer-extra plugin registered stealth/evasions/navigator.webdriver +2ms
  puppeteer-extra-plugin:base:stealth/evasions/navigator.plugins Initialized. +0ms
  puppeteer-extra plugin registered stealth/evasions/navigator.plugins +2ms
  puppeteer-extra-plugin:base:stealth/evasions/window.outerdimensions Initialized. +0ms
  puppeteer-extra plugin registered stealth/evasions/window.outerdimensions +3ms
  puppeteer-extra-plugin:base:stealth/evasions/webgl.vendor Initialized. +0ms
  puppeteer-extra plugin registered stealth/evasions/webgl.vendor +3ms
  puppeteer-extra-plugin:base:stealth/evasions/user-agent Initialized. +0ms
  puppeteer-extra plugin registered stealth/evasions/user-agent +3ms
  puppeteer-extra no dependencies are missing +1ms
  puppeteer-extra orderPlugins:before [ 'anonymize-ua',
  'recaptcha',
  'stealth',
  'stealth/evasions/chrome.runtime',
  'stealth/evasions/console.debug',
  'stealth/evasions/navigator.languages',
  'stealth/evasions/navigator.permissions',
  'stealth/evasions/navigator.webdriver',
  'stealth/evasions/navigator.plugins',
  'stealth/evasions/window.outerdimensions',
  'stealth/evasions/webgl.vendor',
  'stealth/evasions/user-agent' ] +0ms
  puppeteer-extra orderPlugins:after [ 'anonymize-ua',
  'recaptcha',
  'stealth',
  'stealth/evasions/chrome.runtime',
  'stealth/evasions/console.debug',
  'stealth/evasions/navigator.languages',
  'stealth/evasions/navigator.permissions',
  'stealth/evasions/navigator.webdriver',
  'stealth/evasions/navigator.plugins',
  'stealth/evasions/window.outerdimensions',
  'stealth/evasions/webgl.vendor',
  'stealth/evasions/user-agent' ] +0ms
  puppeteer-extra-plugin:recaptcha onPageCreated +0ms
  puppeteer-extra-plugin:anonymize-ua new ua Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36 +0ms
  puppeteer-extra-plugin:recaptcha solveRecaptchas +0ms
  puppeteer-extra-plugin:recaptcha findRecaptchas +0ms
  puppeteer-extra-plugin:recaptcha hasRecaptchaScriptTag false +0ms
  puppeteer-extra-plugin:recaptcha _generateContentScript findRecaptchas undefined +0ms
  puppeteer-extra-plugin:recaptcha findRecaptchas { captchas: [], error: null } +0ms
  puppeteer-extra-plugin:recaptcha solveRecaptchas { captchas: [], solutions: [], solved: [], error: null } +0ms
berstend commented 4 years ago

Hmm, interesting. It doesn't seem to find the captcha in your screenshot.

I have trouble triggering the bot warning on that page πŸ˜„ Are you able to paste the HTML of the page in your screenshot here?

using e.g.

let bodyHTML = await page.evaluate(() => document.body.innerHTML);
berstend commented 4 years ago

Also, could you paste the recaptcha plugin version you're using?

e-moshaya commented 4 years ago

@berstend output of bodyHTML:

<div id="distilIdentificationBlock">&nbsp;</div>

<div id="d__fFH" style="position: absolute !important; top: -5000px !important; left: -5000px !important;"><object id="d_dlg" classid="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></object><span id="d__fF" style="font-family: Courier, serif !important; font-size: 72px !important; visibility: hidden;">The quick brown fox jumps over the lazy dog.</span></div>

I'm using the following versions:

"puppeteer": "^2.0.0",
"puppeteer-extra": "^2.1.6",
"puppeteer-extra-plugin-stealth": "^2.2.5",
"puppeteer-extra-plugin-recaptcha": "^3.0.7",
"puppeteer-extra-plugin-anonymize-ua": "^2.1.7",
berstend commented 4 years ago

Hmm, not sure this is the HTML we're looking for. πŸ˜„ clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b seems to be a "Dialog Helper" for IE.

Looking at the screenshot again: The color of the reCAPTCHA has shifted, which means it has been detected by the plugin. Could this be an issue with your 2captcha.com account? Did you set the token correctly? :)

I will add functionality to test the provided 2captcha credentials in the future.

berstend commented 4 years ago

I just added a warning when the XXXXXXX token from the example is used, in case that was your issue :) Also I just today updated the readme to make it clear that a 2captcha account + api key is required for the plugin to work.

berstend commented 4 years ago

Closing for now, please ping if the issue is a different one.