Skip to content
Nat Lee

Keyboard shortcuts

Turn these off if they get in the way of a screen reader or voice control. The setting is saved in this browser.

1
Home
2
Work
3
Projects
4
About
5
Experience
/
Search projects
?
Show this panel

Web Automation

Pyppeteer Snap

Website Screenshot Tool

The original Pyppeteer screenshot helper. Archived; new work uses playwright-snap with the same function names, arguments and return types.

Role
Creator & Maintainer
Period
2020 – 2021
Status
Archived
Categories
Libraries & tools
Stack
  • Python
  • Pyppeteer
  • Web Scraping
  • Automation
Pyppeteer Snap, screenshot 1

Overview

A Python helper returning website PNG and PDF snapshots as base64. The project is archived because its Pyppeteer browser dependency is no longer maintained. Its successor, playwright-snap, keeps the same API with Playwright-driven Chromium.

How it fits together

Simplified on purpose. The real thing has more arrows and at least one config file nobody understands.

Retired, but its replacement kept every function name.

  1. Caller
    • Python script
    • example/ Flask app
    → URL
  2. This onePyppeSnap
    • get_image_snapshot_by_url
    • get_pdf_snapshot_by_url
    • pyppesnap CLI
    → launches
  3. Headless browser
    • Pyppeteer
    • Its own old Chromium
    → renders
  4. Base64 snapshot
    • PNG as str
    • PDF as bytes

Point at a box to see what it connects to.

The same page twice: a PNG of the 1600 × 900 window and a PDF of the whole page
The same page twice: a PNG of the 1600 × 900 window and a PDF of the whole page

Features

  • PNG and PDF snapshots as base64
  • Python API and command-line interface
The CLI prints base64 (123,256 characters trimmed, mercifully) and pipes into a PDF
The CLI prints base64 (123,256 characters trimmed, mercifully) and pipes into a PDF

Results

  • API carried forward by playwright-snap

What I learned

  • Pyppeteer's last release, 2.0.0, came out in February 2024 with Chromium 117 from 2023; on Python 3.7, pip only reaches Chromium 71, from 2018.
  • Pyppeteer caps websockets below 11 and urllib3 below 2, so installing it can downgrade packages the rest of your code needs.
  • Spin-off · Infortrend
    Libraries & toolsVision & imaging7070 stars on GitHub

    Blur Generator

    Makes perfectly good images worse on purpose: motion, lens, Gaussian and depth-aware blur, for training models that have to cope with bad photos.

    2021Completed
  • Libraries & toolsVision & imaging2626 stars on GitHub

    HEIC2PNG

    Turns iPhone HEIC photos into PNG from the CLI, a shell pipe or Python. A small tool for a small, recurring annoyance.

    2022Completed
  • Spin-off · Infortrend
    Libraries & toolsVision & imaging7676 stars on GitHub

    Batch Crop Images

    Draw a crop box once and it is applied to a whole folder of similar images. Written because I refused to crop them one by one, and apparently other people refused too.

    2019Completed