ScreenAPI

Guides

Full-page screenshots with Puppeteer (and when an API is simpler)

How to take a full-page screenshot with Puppeteer, fix blank lazy-loaded images, hide cookie banners and avoid memory issues, and when a screenshot API saves you the trouble.

Puppeteer drives a headless Chrome from Node.js. One option, fullPage: true, turns a viewport capture into a capture of the whole scrollable page. The basics take five lines; the pitfalls take longer.

The basic full-page screenshot

import puppeteer from "puppeteer";

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({ width: 1280, height: 800 });
await page.goto("https://example.com", { waitUntil: "networkidle2" });
await page.screenshot({ path: "full.png", fullPage: true });
await browser.close();

waitUntil: "networkidle2" waits until the network is almost quiet, which is usually enough for the main content to be there.

Pitfall 1: lazy-loaded images come out blank

Many sites only load images when they scroll into view. A full-page capture does not scroll, so the bottom of the page shows grey boxes. Scroll through the page first:

await page.evaluate(async () => {
  for (let y = 0; y < document.body.scrollHeight; y += window.innerHeight) {
    window.scrollTo(0, y);
    await new Promise((r) => setTimeout(r, 200));
  }
  window.scrollTo(0, 0);
});
await page.screenshot({ path: "full.png", fullPage: true });

Pitfall 2: cookie banners and chat bubbles

Consent banners cover the top or bottom of most European sites. You can click "accept" if you know the button, or hide the usual containers with CSS:

await page.addStyleTag({
  content: "#onetrust-banner-sdk, .cc-window, #CybotCookiebotDialog, .intercom-lightweight-app { display: none !important; }",
});

The list of selectors never ends: every consent tool and chat widget uses its own.

Pitfall 3: memory and servers

  • Each Chrome tab uses a few hundred megabytes; very long pages can use much more.
  • Always close pages and the browser in a finally block, or zombie Chrome processes pile up.
  • Serverless platforms limit package size and memory: you often need a special Chrome build.
  • Fonts for Chinese, Japanese or emoji must be installed on the server or text shows as boxes.

The same capture with an API

If you only need the picture, ScreenAPI runs the browser for you. Lazy loading, cookie banners and chat widgets are handled by parameters:

curl "https://getscreenapi.com/api/v1/screenshot?url=https://example.com&full_page=true&lazy_load=true&block_chats=true" \
  -H "x-api-key: YOUR_KEY" -o full.png

Cookie banners are hidden by default. See also the Node.js guide and the full parameter list.

Which one to choose?

PuppeteerScreenshot API
CostFree library, you pay the server100 free/month, then from €9/month
SetupChrome on every machineOne HTTP call
ControlTotal: any script, any login flowParameters (click, CSS, JS, wait)
Best forPages behind your own login, complex flowsPublic pages, previews, PDFs, many languages

Try the API on your own pages: 100 free captures a month.

Get a free key