← Til baka

How to Capture Website Screenshots Programmatically in 2026

· 5 mín lestrartími · Developer Tools

Need to capture website screenshots in your application? Whether you're building a link preview feature, monitoring dashboards, or generating thumbnails, there are several approaches. Here's a practical comparison of the most popular methods in 2026.

1. Headless Browser (Puppeteer / Playwright)

The DIY approach. You run a headless Chromium instance and capture screenshots directly.

// Node.js with Puppeteer
const puppeteer = require('puppeteer');
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'screenshot.png' });
await browser.close();

Pros: Full control, no external dependencies.
Cons: Resource-heavy (500MB+ RAM per instance), slow cold starts, you manage scaling and browser updates.

2. Screenshot API (Recommended for Production)

The simplest approach — one HTTP request, no infrastructure to manage.

# cURL — that's it
curl "https://api.pandan.is/v1/screenshot?url=https://example.com" -o screenshot.png

# With options
curl "https://api.pandan.is/v1/screenshot?url=https://example.com&width=1920&height=1080&format=jpeg&quality=90" -o screenshot.jpg
# Python
import requests
response = requests.get('https://api.pandan.is/v1/screenshot', params={'url': 'https://example.com'})
with open('screenshot.png', 'wb') as f:
    f.write(response.content)

Pros: Zero infrastructure, fast (under 3 seconds), handles scaling automatically, free tier with 100 screenshots/month.
Cons: External dependency, rate limits on free tier.

Try Pandan Screenshot API free →

3. Selenium WebDriver

The classic automation tool. Heavier than Puppeteer but supports multiple browsers.

# Python with Selenium
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
driver = webdriver.Chrome(options=options)
driver.get('https://example.com')
driver.save_screenshot('screenshot.png')
driver.quit()

Pros: Multi-browser support, mature ecosystem.
Cons: Slowest option, complex setup, heavy resource usage.

4. Node.js with html2canvas

Client-side rendering — useful if you need to capture your own app's state.

// Browser-side
import html2canvas from 'html2canvas';
const canvas = await html2canvas(document.body);
const dataUrl = canvas.toDataURL('image/png');

Pros: No server needed, captures exact client state.
Cons: Only works for your own pages, limited CSS support, can't capture external URLs.

5. PDF Generation as Alternative

Sometimes a PDF is more useful than an image — for reports, invoices, or archiving.

# Generate PDF of any webpage
curl "https://api.pandan.is/v1/pdf?url=https://example.com" -o page.pdf

Which Method Should You Choose?

MethodSetup TimeCostSpeedBest For
Screenshot API0 minFree–$49/mo~2sProduction apps
Puppeteer30 minServer costs~5sCustom workflows
Playwright30 minServer costs~4sMulti-browser needs
Selenium60 minServer costs~8sLegacy integration
html2canvas10 minFree~1sOwn pages only

For most production use cases, an API is the fastest path. Pandan Screenshot API gives you 100 free screenshots per month — enough to test and prototype. Scale up to Pro ($9/mo) or Business ($49/mo) when you're ready.

Related Tools