Mastering Puppeteer Stealth to Beat Anti Bot Systems with Ease

SwiftProxy
By - Martin Koenig
2025-05-24 15:10:06

Mastering Puppeteer Stealth to Beat Anti Bot Systems with Ease

Websites are no longer fooled by simple bots. Cloudflare, advanced anti-spam systems, and clever detection scripts are catching automated traffic every day. If Puppeteer isn't tuned right, you'll face bans, captchas, and endless blocks. Frustrating? Absolutely. But it doesn't have to be that way.

Puppeteer Stealth is your secret weapon. It disguises your bot as a real user — masking fingerprints, simulating mouse movements, and wiping automation traces clean. This guide will take you step-by-step through setting up Puppeteer Stealth so your scraping scripts glide past defenses like a pro.

Step 1: Install Puppeteer and Enable Stealth Mode

Setting up Stealth mode is easier than you think. Just a few commands, a little configuration, and you're good to go.

Run this in your terminal:

npm install puppeteer puppeteer-extra puppeteer-extra-plugin-stealth

Here's what each package does:

puppeteer: Controls Chrome or Chromium.

puppeteer-extra: Framework to add plugins.

puppeteer-extra-plugin-stealth: The magic layer that hides automation signs.

By default, Puppeteer reveals itself—headers say HeadlessChrome, and detectable automation flags remain. Stealth mode flips the script.

Next, create an index.js file with this:

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

puppeteer.use(StealthPlugin());

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  const page = await browser.newPage();

  await page.goto('https://bot.sannysoft.com/');
  await page.screenshot({ path: 'result.png' });

  console.log('Test complete. Screenshot saved.');
  await browser.close();
})();

Run it, then check result.png. The site will show how well your bot is disguised.

Step 2: Add Startup Parameters for Extra Stealth

Stealth mode is great, but you can push it further. Adjust the launch options to improve performance and dodge common server defenses:

const browser = await puppeteer.launch({
  headless: true,
  args: [
    '--no-sandbox',
    '--disable-setuid-sandbox',
    '--disable-dev-shm-usage',
    '--disable-accelerated-2d-canvas',
    '--disable-gpu'
  ]
});

Why these? They cut unnecessary overhead and avoid conflicts that might trigger suspicion.

Step 3: Test Against Real-World Sites

Before you hit production, verify your setup on these trusted sites:

bot.sannysoft.com — Detects bots by behavior.

whatismybrowser.com — Reveals your browser fingerprint.

httpbin.org/headers — Shows HTTP headers sent with requests.

Run your bot, grab screenshots, analyze results. If you spot automation flags, tweak your settings.

Step 4: Use Proxies to Disguise Your IP

One IP address? It's a dead giveaway. Proxies rotate your origin, spreading requests across many IPs. This drastically reduces bans.

Choose your proxy type carefully:

Server proxies: Fast, stable, great for bulk scraping.

Mobile proxies: Use real mobile IPs, harder to detect.

Plug in proxies using Puppeteer's launch args:

const browser = await puppeteer.launch({
  headless: true,
  args: ['--proxy-server=http://username:password@proxy_address:port']
});

Replace with your proxy details. Simple.

Step 5: Rotate Proxies to Stay Under the Radar

Static proxies get flagged fast. Rotate them on every request.

Here's a snippet for random proxy rotation:

const proxyList = [
  'http://user1:pass1@proxy1:port',
  'http://user2:pass2@proxy2:port',
  'http://user3:pass3@proxy3:port'
];

const getRandomProxy = () => proxyList[Math.floor(Math.random() * proxyList.length)];

(async () => {
  for (let i = 0; i < 5; i++) {
    const proxy = getRandomProxy();
    const browser = await puppeteer.launch({
      headless: true,
      args: [\`--proxy-server=${proxy}\`]
    });
    const page = await browser.newPage();
    await page.goto('https://httpbin.org/ip');
    console.log(\`Request via proxy: ${proxy}\`);
    await browser.close();
  }
})();

Each run uses a different IP, spreading your traffic footprint.

Step 6: Validate Proxies for Stability and Speed

Before scaling up:

Test each proxy with multiple page loads.

Check latency—slow proxies kill efficiency.

Match proxy location to your target data region.

For example, if scraping US-only content, use US proxies.

Step 7: Final Stealth Testing and Debugging

No setup is perfect out of the box. Test often. Use the sites above to confirm your bot passes as human.

If you get blocked or flagged:

Review browser fingerprints.

Check headers carefully.

Adjust stealth plugin settings or add more browser mimicry.

In Summary

Configuring Puppeteer Stealth isn't magic, but it's close. With the right plugins, smart proxies, and thorough testing, your bot can move through defenses undetected. This lets your scripts run uninterrupted, collecting data with confidence.

Note sur l'auteur

SwiftProxy
Martin Koenig
Responsable Commercial
Martin Koenig est un stratège commercial accompli avec plus de dix ans d'expérience dans les industries de la technologie, des télécommunications et du conseil. En tant que Responsable Commercial, il combine une expertise multisectorielle avec une approche axée sur les données pour identifier des opportunités de croissance et générer un impact commercial mesurable.
Le contenu fourni sur le blog Swiftproxy est destiné uniquement à des fins d'information et est présenté sans aucune garantie. Swiftproxy ne garantit pas l'exactitude, l'exhaustivité ou la conformité légale des informations contenues, ni n'assume de responsabilité pour le contenu des sites tiers référencés dans le blog. Avant d'engager toute activité de scraping web ou de collecte automatisée de données, il est fortement conseillé aux lecteurs de consulter un conseiller juridique qualifié et de revoir les conditions d'utilisation applicables du site cible. Dans certains cas, une autorisation explicite ou un permis de scraping peut être requis.
FAQ

Mastering Puppeteer Stealth to Beat Anti Bot Systems with Ease

Websites are no longer fooled by simple bots. Cloudflare, advanced anti-spam systems, and clever detection scripts are catching automated traffic every day. If Puppeteer isn't tuned right, you'll face bans, captchas, and endless blocks. Frustrating? Absolutely. But it doesn't have to be that way.

Puppeteer Stealth is your secret weapon. It disguises your bot as a real user — masking fingerprints, simulating mouse movements, and wiping automation traces clean. This guide will take you step-by-step through setting up Puppeteer Stealth so your scraping scripts glide past defenses like a pro.

Step 1: Install Puppeteer and Enable Stealth Mode

Setting up Stealth mode is easier than you think. Just a few commands, a little configuration, and you're good to go.

Run this in your terminal:

npm install puppeteer puppeteer-extra puppeteer-extra-plugin-stealth

Here's what each package does:

puppeteer: Controls Chrome or Chromium.

puppeteer-extra: Framework to add plugins.

puppeteer-extra-plugin-stealth: The magic layer that hides automation signs.

By default, Puppeteer reveals itself—headers say HeadlessChrome, and detectable automation flags remain. Stealth mode flips the script.

Next, create an index.js file with this:

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

puppeteer.use(StealthPlugin());

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  const page = await browser.newPage();

  await page.goto('https://bot.sannysoft.com/');
  await page.screenshot({ path: 'result.png' });

  console.log('Test complete. Screenshot saved.');
  await browser.close();
})();

Run it, then check result.png. The site will show how well your bot is disguised.

Step 2: Add Startup Parameters for Extra Stealth

Stealth mode is great, but you can push it further. Adjust the launch options to improve performance and dodge common server defenses:

const browser = await puppeteer.launch({
  headless: true,
  args: [
    '--no-sandbox',
    '--disable-setuid-sandbox',
    '--disable-dev-shm-usage',
    '--disable-accelerated-2d-canvas',
    '--disable-gpu'
  ]
});

Why these? They cut unnecessary overhead and avoid conflicts that might trigger suspicion.

Step 3: Test Against Real-World Sites

Before you hit production, verify your setup on these trusted sites:

bot.sannysoft.com — Detects bots by behavior.

whatismybrowser.com — Reveals your browser fingerprint.

httpbin.org/headers — Shows HTTP headers sent with requests.

Run your bot, grab screenshots, analyze results. If you spot automation flags, tweak your settings.

Step 4: Use Proxies to Disguise Your IP

One IP address? It's a dead giveaway. Proxies rotate your origin, spreading requests across many IPs. This drastically reduces bans.

Choose your proxy type carefully:

Server proxies: Fast, stable, great for bulk scraping.

Mobile proxies: Use real mobile IPs, harder to detect.

Plug in proxies using Puppeteer's launch args:

const browser = await puppeteer.launch({
  headless: true,
  args: ['--proxy-server=http://username:password@proxy_address:port']
});

Replace with your proxy details. Simple.

Step 5: Rotate Proxies to Stay Under the Radar

Static proxies get flagged fast. Rotate them on every request.

Here's a snippet for random proxy rotation:

const proxyList = [
  'http://user1:pass1@proxy1:port',
  'http://user2:pass2@proxy2:port',
  'http://user3:pass3@proxy3:port'
];

const getRandomProxy = () => proxyList[Math.floor(Math.random() * proxyList.length)];

(async () => {
  for (let i = 0; i < 5; i++) {
    const proxy = getRandomProxy();
    const browser = await puppeteer.launch({
      headless: true,
      args: [\`--proxy-server=${proxy}\`]
    });
    const page = await browser.newPage();
    await page.goto('https://httpbin.org/ip');
    console.log(\`Request via proxy: ${proxy}\`);
    await browser.close();
  }
})();

Each run uses a different IP, spreading your traffic footprint.

Step 6: Validate Proxies for Stability and Speed

Before scaling up:

Test each proxy with multiple page loads.

Check latency—slow proxies kill efficiency.

Match proxy location to your target data region.

For example, if scraping US-only content, use US proxies.

Step 7: Final Stealth Testing and Debugging

No setup is perfect out of the box. Test often. Use the sites above to confirm your bot passes as human.

If you get blocked or flagged:

Review browser fingerprints.

Check headers carefully.

Adjust stealth plugin settings or add more browser mimicry.

In Summary

Configuring Puppeteer Stealth isn't magic, but it's close. With the right plugins, smart proxies, and thorough testing, your bot can move through defenses undetected. This lets your scripts run uninterrupted, collecting data with confidence.

Charger plus
Afficher moins
SwiftProxy SwiftProxy SwiftProxy
SwiftProxy