noderank . dev
All posts
SEO · 3 min read

SERP scraping with Puppeteer that doesn't get banned

A practical playbook for scraping Google search results at small-to-medium scale without burning a fortune on anti-bot SaaS.

ShareCopied!

Every SEO project eventually needs to scrape search results. The canonical answer is “use a SERP API and pay per query” — and sometimes that’s the right call. But if your volume is under a few thousand queries a day, rolling your own with Puppeteer is cheaper, more flexible, and surprisingly reliable if you avoid a few traps.

Here’s the playbook I use.

The core idea

Treat Google the way you’d treat any well-defended API: respect the rate limits, rotate fingerprints, and bail early on signs of trouble.

import puppeteer from 'puppeteer-extra';
import Stealth from 'puppeteer-extra-plugin-stealth';

puppeteer.use(Stealth());

const browser = await puppeteer.launch({
  headless: 'new',
  args: ['--no-sandbox', '--disable-blink-features=AutomationControlled'],
});

The puppeteer-extra-plugin-stealth plugin patches about 20 different “am I a bot” checks that Chrome exposes by default. You want it on day one.

Rotate everything that can be rotated

Google doesn’t just look at your IP — it looks at the combination of IP, user agent, viewport, language header, timezone, and screen resolution. If you always send the same fingerprint, you’ll get flagged even behind residential proxies.

I keep a small pool of fingerprints and pick one per query:

const fingerprints = [
  { ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_5) ...', viewport: { width: 1440, height: 900 }, locale: 'en-US' },
  { ua: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) ...',    viewport: { width: 1920, height: 1080 }, locale: 'en-GB' },
  // ... 10–20 more
];

const fp = fingerprints[Math.floor(Math.random() * fingerprints.length)];
await page.setUserAgent(fp.ua);
await page.setViewport(fp.viewport);
await page.setExtraHTTPHeaders({ 'Accept-Language': fp.locale });

Slow down on purpose

The biggest mistake I see in beginner scrapers is firing off 100 queries in parallel and wondering why they get blocked after 20. Real users don’t browse like that.

I run at one query every 8–15 seconds, with jitter. For a few hundred queries a day, that’s enough to stay under the radar without any proxies.

async function sleep(min: number, max: number) {
  const ms = min + Math.random() * (max - min);
  return new Promise((r) => setTimeout(r, ms));
}

for (const keyword of keywords) {
  const results = await scrapeSerp(keyword);
  await save(results);
  await sleep(8_000, 15_000);
}

Detect soft bans early

Google rarely returns a 403. Instead, it quietly starts serving the “unusual traffic” captcha page or a stripped-down results page. Detect both and bail:

const isCaptcha = await page.$('form[action^="/sorry"]') !== null;
const isThin = (await page.$$('div.g')).length < 3;
if (isCaptcha || isThin) {
  throw new Error('soft-banned');
}

When you hit a soft ban, stop the whole run, wait at least 20 minutes, and consider rotating to a different IP before resuming. Retrying immediately is the fastest way to get fully blocked.

When to give up and pay for a SERP API

If you’re doing more than ~5,000 queries a day, the math stops working. Residential proxy costs and the time you spend debugging anti-bot updates will eat your savings. At that scale, pay for SerpApi or a similar service and focus your engineering time elsewhere.

Under 5k/day, rolling your own is still the right call — and with the approach above, you can keep it running for months without touching it.

ShareCopied!