DEV Community

Alex Spinov
Alex Spinov

Posted on

Puppeteer Has a Free Browser Automation Library — Scrape, Screenshot, and PDF from Node.js

Puppeteer controls Chrome/Chromium programmatically from Node.js. Generate PDFs, take screenshots, scrape single-page apps, and automate form submissions.

What You Get for Free

Screenshot:

import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'screenshot.png', fullPage: true });
await browser.close();
Enter fullscreen mode Exit fullscreen mode

PDF generation:

await page.goto('https://myapp.com/invoice/123');
await page.pdf({
  path: 'invoice.pdf',
  format: 'A4',
  printBackground: true,
  margin: { top: '1cm', bottom: '1cm' },
});
Enter fullscreen mode Exit fullscreen mode

Scraping SPAs (JavaScript-rendered content):

await page.goto('https://spa-site.com/products');
await page.waitForSelector('.product-card');

const products = await page.evaluate(() => {
  return Array.from(document.querySelectorAll('.product-card')).map(el => ({
    name: el.querySelector('h3')?.textContent,
    price: el.querySelector('.price')?.textContent,
  }));
});
Enter fullscreen mode Exit fullscreen mode

Form automation:

await page.type('#email', 'user@test.com');
await page.type('#password', 'password');
await page.click('#login-button');
await page.waitForNavigation();
Enter fullscreen mode Exit fullscreen mode

Core Features

  • Headless by default — runs without visible browser
  • Full Chrome DevTools Protocol — access to network, console, performance
  • Request interception — block ads, modify requests, mock APIs
  • Cookie management — set, get, delete cookies
  • Viewport emulation — test responsive designs programmatically
  • Network monitoring — capture all requests and responses

Quick Start

npm i puppeteer  # downloads Chromium
Enter fullscreen mode Exit fullscreen mode

Common Use Cases

  • Invoice/report PDF generation in web apps
  • Social media preview screenshots (Open Graph images)
  • Visual regression testing — compare screenshots before/after changes
  • Web scraping — extract data from JavaScript-heavy sites
  • Performance monitoring — measure load times, Core Web Vitals

If you need to automate anything in a browser — Puppeteer does it with a clean, modern API.


Need web scraping or data extraction? Check out my tools on Apify — get structured data from any website in minutes.

Custom solution? Email spinov001@gmail.com — quote in 2 hours.

Top comments (0)