Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { chromium } = require('playwright-extra')
- const RecaptchaPlugin = require('puppeteer-extra-plugin-recaptcha')
- // Set the environment variables for the 2Captcha proxy
- process.env['2CAPTCHA_PROXY_TYPE'] = 'HTTP'; // Adjust based on your proxy type
- process.env['2CAPTCHA_PROXY_ADDRESS'] = 'YOUR_PROXY_ADDRESS'; // Replace with your proxy address
- // add recaptcha plugin and provide it your 2captcha credentials
- 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 on check button.
- await page.click('button.l2z7-tVRGe-3sq5kU4uu5');
- 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