Bypassing CAPTCHAs with Headless Chrome using pupp

2020-02-10 01:11发布

问题:

google finds my browser is being manipulated/controlled/automated by software, and because of that I get reCaptcha. When I manual start chromium and do the same steps the reCaptcha doesn't appear.

Question 1)

Is it possible to solve captcha Programmatically or get rid of it when using puppeteer? Any way to solve this?

Question 2)

Does this happens only when without headless option i.e

const browser = await puppeteer.launch({
  headless: false
})

OR this is something the fact we have to accept and move on?

回答1:

Have you tried setting the browser agent?

await page.setUserAgent('5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36');


回答2:

Try generating random useragent using this npm package. This usually solves the user agent-based protection.

In puppeteer pages can override browser user agent with page.setUserAgent

var userAgent = require('user-agents');
...
await page.setUserAgent(userAgent.toString())

Additionally, you can add these two extra plugins,

puppeteer-extra-plugin-recaptcha - Solves reCAPTCHAs automatically, using a single line of code: page.solveRecaptchas()

puppeteer-extra-plugin-stealth - Applies various evasion techniques to make detection of headless puppeteer harder.