Can't force puppeteer to click on recaptcha in iframe

Viewed 1553

I'm writing a bot with which I can create accounts on several pages.
I have to develop my anticaptcha alghoritm (based on audio - already done).
I tried to do it with python + selenium but after clicking recaptcha button I got the following message
We're sorry, but your computer or network may be sending automated queries...
Now I'm trying to do it with puppeteer. Here is code example:

const puppeteer = require('puppeteer-extra')
const StealthPlugin = require('puppeteer-extra-plugin-stealth')
puppeteer.use(StealthPlugin())

let browser = puppeteer.launch({ headless: false }).then(async browser => {
    const page = await browser.newPage()
    await page.goto('https://nubela.co/proxycurl/')

    const frameHandle = await page.$("iframe");
    const frame = await frameHandle.contentFrame();
    await frame.click('.recaptcha-checkbox-border')
    await page.screenshot({ path: 'res.png', fullPage: true })
    await browser.close()
})

I'm getting "TypeError: Cannot read property 'click' of null".
I tried to iterate over frames but it does not work too...

2 Answers

so here are some fun facts:

  1. the recaptcha is deliberately a thing that you're not supposed to be able to automate. This thing exists for 1 and 1 purpose only - prevent any form of automation

  2. Still you can touch the components inside an iframe by executing custom JS inside your browser. Here's how you can tell puppeteer to run a custom JS inside your browser: https://dev.to/benjaminmock/executing-javascript-in-the-page-context-of-puppeteer-fp8

and here's how to manipulate an object within an inframe from JS: https://www.w3schools.com/howto/howto_js_element_iframe.asp

so you will need to make a custom browser js script that clicks your button within an iframe and make puppeteer execute it

The site you entered has Cloudflare-UAM! Since your script does not have a bypass of this protection, the browser encounters the protection and the action with the captcha comes out as an error, because there is no Recaptcha on the verification page.

Related