https://github.com/luminati-io/puppeteer-bypass-captcha
Bypass CAPTCHAs using Puppeteer with stealth mode. For tougher WAFs, try extra plugins or Bright Data’s Web Unlocker API.
https://github.com/luminati-io/puppeteer-bypass-captcha
captcha captcha-solver javascript puppeteer
Last synced: about 1 month ago
JSON representation
Bypass CAPTCHAs using Puppeteer with stealth mode. For tougher WAFs, try extra plugins or Bright Data’s Web Unlocker API.
- Host: GitHub
- URL: https://github.com/luminati-io/puppeteer-bypass-captcha
- Owner: luminati-io
- Created: 2024-12-31T09:35:41.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-12-31T11:51:30.000Z (4 months ago)
- Last Synced: 2025-03-22T07:02:03.218Z (about 1 month ago)
- Topics: captcha, captcha-solver, javascript, puppeteer
- Homepage: https://brightdata.com/products/web-unlocker
- Size: 3.91 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bypass CAPTCHAs With Puppeteer
[](https://brightdata.com/products/web-unlocker)
A quick guide to bypass CAPTCHAs by mimicking human behavior with Puppeteer. Skip the guide by signing up to Bright Data and opting-in for the [Web Unlocker API](https://brightdata.com/products/web-unlocker).
## Step 1: Project Setup
```bash
mkdir bypass_captcha_puppeteer
cd bypass_captcha_puppeteer
npm init -y
npm install puppeteer
```Structure:
```bash
bypass_captcha_puppeteer/
├── index.js
└── package.json
```Include ```"type"```: ```"module"``` in ```package.json```:
```json
{
"name": "bypass_captcha_puppeteer",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"puppeteer": "^23.10.4"
}
}
```## Step 2: Test Puppeteer (No Stealth)
```javascript
import puppeteer from 'puppeteer';
const visitBotAnalyzerPage = async () => {
try {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const url = 'https://bot.sannysoft.com/';
console.log(`Navigating to ${url}...`);
await page.goto(url, { waitUntil: 'networkidle2' });
console.log('Taking full-page screenshot...');
await page.screenshot({ path: 'anti-bot-analysis.png', fullPage: true });
console.log('Screenshot taken');
await browser.close();
console.log('Browser closed');
} catch (error) {
console.error('An error occurred:', error);
}
};
// run the script
visitBotAnalyzerPage();
```Run:
```bash
node index.js
```You may fail some bot checks, prompting CAPTCHAs.
## Step 3: Install Stealth Plugin
```bash
npm install puppeteer-extra puppeteer-extra-plugin-stealth
```Replace ```puppeteer``` import with ```puppeteer-extra``` and add the plugin:
```javascript
import puppeteer from 'puppeteer-extra';
import StealthPlugin from 'puppeteer-extra-plugin-stealth';// Add the stealth plugin
puppeteer.use(StealthPlugin());const visitBotAnalyzerPage = async () => {
try {
const browser = await puppeteer.launch();
console.log('Launching browser in stealth mode...');
const page = await browser.newPage();
const url = 'https://bot.sannysoft.com/';
console.log(`Navigating to ${url}...`);
await page.goto(url, { waitUntil: 'networkidle2' });
console.log('Taking full-page screenshot...');
await page.screenshot({ path: 'anti-bot-analysis.png', fullPage: true });
console.log(`Screenshot taken`);
await browser.close();
console.log('Browser closed. Script completed successfully');
} catch (error) {
console.error('Error occurred:', error);
}
};
// run the script
visitBotAnalyzerPage();
```Run again:
```bash
node index.js
```Stealth reduces bot detection and CAPTCHAs.
## If Stealth Isn’t Enough
For advanced WAFs and bot detection, try extra plugins (e.g., ```puppeteer-extra-plugin-anonymize-ua```) or dedicated tools. Tools like [Bright Data’s Web Unlocker API](https://brightdata.com/products/web-unlocker) handle reCAPTCHA, hCaptcha, and a lot more.