Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { chromium } = require('playwright-extra')
- // add recaptcha plugin and provide it your 2captcha credentials
- const RecaptchaPlugin = require('puppeteer-extra-plugin-recaptcha')
- chromium.use(
- RecaptchaPlugin({
- provider: {
- id: '2captcha',
- token: 'Your_API_key' // REPLACE THIS WITH YOUR OWN 2CAPTCHA API KEY ⚡
- }
- })
- )
- //Launch Chromium browser in headless mode
- chromium.launch({ headless: true }).then(async browser => {
- // Open a new page
- const page = await browser.newPage();
- // Navigate to target URL
- await page.goto('https://2captcha.com/demo/recaptcha-v2', { waitUntil: 'networkidle' });
- // The single line of code to solve reCAPTCHAs
- await page.solveRecaptchas()
- // Click the Check button
- await page.click('text=Check');
- // Wait a few seconds
- await page.waitForTimeout(5000);
- console.log('Taking a screenshot...');
- // Take a screenshot and save to project folder
- await page.screenshot({ path: 'screenshot.png', fullPage: true });
- console.log('Screenshot saved');
- await browser.close();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement