Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › browser automation

How to Bulk Screenshot Pages and Preserve Each URL in the Filename

By Freedom251 Team · · 7 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a browser automation tool to capture each URL and build the output filename from that URL. For reliable batches, sanitize the URL for filesystem use, add a short hash to prevent collisions, and keep a manifest mapping each saved image to its original URL. Playwright gives you flexible control in code; shot-scraper offers a YAML-driven multi-page workflow.

Choose a batch workflow

For a recurring or custom job, use Playwright: you can control navigation, readiness checks, filenames, and failures in one script. For a known list with straightforward capture settings, shot-scraper’s multi command reads a YAML file with a URL and output path for each image. Playwright CLI is handy for one-off captures, but a script or configuration is easier to maintain as a batch grows.

As an Amazon Associate I earn from qualifying purchases.

These approaches differ in flexibility, not in a universal maximum batch size. The cited documentation does not establish a best tool for every batch or site type.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Playwright to name screenshots from URLs

Install Playwright and its Chromium browser in a Node.js project using the Playwright documentation. Save one URL per line in urls.txt, then create capture.mjs with the following script. It records both the requested URL and final URL, writes a filename based on the host and path, and adds a short SHA-256 suffix so similar paths or query variants do not overwrite one another.

#1 Best Overall
Sandisk 2TB Extreme Portable SSD, Up to 1050MB/s, USB-C, USB 3.2 Gen 2, IP65 Water and Dust Resistance, Updated Firmware, External Solid State Drive, SDSSDE61-2T00-G25
  • Get NVMe solid state performance with up to 1050MB/s read and 1000MB/s write speeds in a portable, high-capacity drive(1) (Based on internal testing; performance may be lower depending on host device & other factors. 1MB=1,000,000 bytes.)
  • Up to 3-meter drop protection and IP65 water and dust resistance mean this tough drive can take a beating(3) (Previously rated for 2-meter drop protection and IP55 rating. Now qualified for the higher, stated specs.)
  • Use the handy carabiner loop to secure it to your belt loop or backpack for extra peace of mind.
  • Help keep private content private with the included password protection featuring 256‐bit AES hardware encryption.(3)
  • Easily manage files and automatically free up space with the SanDisk Memory Zone app.(5). Non-Operating Temperature -20°C to 85°C
import { chromium } from 'playwright';
import { createHash } from 'node:crypto';
import { mkdir, readFile, writeFile } from 'node:fs/promises';
import path from 'node:path';

const outputDir = 'screenshots';
const urls = (await readFile('urls.txt', 'utf8'))
  .split(/r?n/)
  .map(line => line.trim())
  .filter(Boolean);

await mkdir(outputDir, { recursive: true });
const browser = await chromium.launch();
const manifest = [];

try {
  for (const [index, url] of urls.entries()) {
    const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
    const safePart = new URL(url).hostname + new URL(url).pathname;
    const slug = safePart
      .replace(/[^a-zA-Z0-9._-]+/g, '-')
      .replace(/-+/g, '-')
      .replace(/^[-.]+|[-.]+$/g, '')
      .slice(0, 100) || 'page';
    const hash = createHash('sha256').update(url).digest('hex').slice(0, 10);
    const filename = `${String(index + 1).padStart(3, '0')}-${slug}-${hash}.png`;
    const outputPath = path.join(outputDir, filename);

    try {
      await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 });
      await page.screenshot({ path: outputPath, fullPage: true });
      manifest.push({ url, finalUrl: page.url(), filename, status: 'ok' });
    } catch (error) {
      manifest.push({ url, filename, status: 'error', error: String(error) });
    } finally {
      await page.close();
    }
  }
} finally {
  await browser.close();
  await writeFile('screenshots-manifest.json', JSON.stringify(manifest, null, 2));
}

Run it with node capture.mjs. The script writes PNGs under screenshots/ and a JSON manifest beside them. It uses domcontentloaded as a reasonable starting point, not a guarantee that every site’s important content is ready. For pages with late-loading content, replace that wait with a page-specific condition—for example, waiting for a selector that identifies the content you need—before taking the screenshot.

What the filename preserves

The host and path make files readable; the hash differentiates URLs that would otherwise map to the same cleaned text, including URLs with different query strings. The numeric prefix also preserves the input order. The filename is not a reversible encoding of the full URL, so the manifest retains the exact original URL and the final URL after redirects.

Sanitization rules are implementation choices rather than a canonical standard prescribed by Playwright. The script replaces characters that are awkward in filenames, compresses repeated hyphens, trims edge punctuation, and caps the readable portion. If your workflow requires reversible provenance, use the manifest rather than trying to reconstruct the URL from the filename.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sandisk 1TB Portable SSD, Up to 800MB/s Read Speeds, Black (Old Model) | External Solid State Drive, Compatible with Laptops & Tablets, Up to 2M Drop Protection, USB 3.2 Gen 2, USB-C to USB-A Cable
  • Solid state performance with up to 800MB/s read speeds in a portable drive. (Based on internal testing; performance may be lower depending on host device, interface, usage conditions and other factors. 1MB=1,000,000 bytes.)
  • Back up your content and memories on a storage solution that fits seamlessly into your mobile lifestyle.
  • Take it with you on your adventures—up to two-meter drop protection means this durable drive can take a beating. (Based on internal testing.)
  • Secure it to your belt loop or backpack for extra peace of mind thanks to the tough rubber hook.
  • From Sandisk, a brand professional photographers trust to take on assignments.

Configure multiple URLs with shot-scraper

For a configuration-based batch, create a YAML file with an entry per page, specifying each url and output. Then run the documented shot-scraper multi command against that file. The shot-scraper documentation shows this workflow and supports per-image dimensions, waits, and selectors. Set explicit output names for predictable URL-linked filenames; the single-page command’s URL-derived default is not a substitute for naming every output deliberately in a batch.

Use the same slug-and-hash principle as in the Playwright example when choosing YAML output names. The documentation does not prescribe a standard sanitization, URL encoding, or collision policy.

Choose viewport or full-page capture

  • Viewport: captures what is visible in the browser window. Use it when comparing page layouts at a fixed screen size.
  • Full page: captures the page’s full scrollable document as one tall image. Playwright’s API supports fullPage: true; its CLI also has a --full-page option. Very long pages can produce unwieldy files, so use full-page capture when the whole page is useful to inspect.

For visual comparisons, keep the browser, viewport dimensions, device scale, and capture timing consistent. Playwright notes that rendering can vary with operating system, browser version, settings, hardware, power source, and headless mode in its visual comparisons documentation.

Rank #3
SSK Portable SSD 500GB External Solid State Hard Drive USB C Up to 1050MB/s
  • Capacity Display Variance: 500GB external ssd often appears as around 465GB on Windows. MacOS can show full 500 GB capacity. This is binary calculation difference and doesn’t affect SSD hard drive actual physical storage
  • 1050 MB/s Speed: Instantly access to your files with blazing-fast 10Gbps external SSD read up to 1050MB/s and write up to 1000MB/s. LED Light indicates USB SSD instant activity
  • Data Security: Solid state drives S.M.A.R.T. health diagnostics​ and adaptive TRIM optimizing data block management ensures consistent write speeds and extends the longevity of the portable SSD
  • USB-C & USB-A Cable: Both cables featuring rapid USB 3.2 Gen2, this USB SSD effortlessly bridges devices, enabling seamless cross-platform file transfers and backup between computers, smartphones, tablets and iPhone
  • Always Fast: No slowdowns for large file transfers. With SLC caching (25% of current available capacity allocated as high-speed cache), this external SSD delivers steady 10Gbps for transfers within the cache capacity

Playwright’s screenshot API supports CSS-pixel and device-pixel scale. CSS scale produces one output pixel per CSS pixel; device scale uses device pixels and can create larger images on high-DPI setups. See the screenshot API options when image dimensions matter.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep the batch auditable and handle failures

Store the requested URL, final URL when redirects matter, output filename, capture time, and status for every item. The example manifest records most of these fields; add a timestamp if the capture set needs a time record. Keep failed entries instead of silently skipping them, so a partial batch is visible and can be rerun selectively.

  • Duplicate or overwritten files: use an index and URL hash in addition to the sanitized host and path.
  • Missing or incomplete page content: replace a generic load event with a condition tied to the page content you need. A fixed delay can help on a known site, but a page-specific readiness check is more robust where load times vary.
  • Changing screenshots between runs: dynamic content, animations, personalization, cookie banners, and delayed assets can change captures. Handle these based on the site and comparison goal rather than assuming one universal delay.
  • Very long images: choose viewport captures if the task is a consistent screen comparison; use full-page capture only when the complete document is needed.
  • Redirected pages: preserve both the input URL and final browser URL in the manifest so the filename’s identity can be checked against what was actually captured.

Or skip the browser setup

ScreenshotNeo can capture a URL through one request, with output formats including PNG, JPEG, WebP, or PDF. Before capture, it accepts the cookie or consent banner as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. It also provides an MCP server with screenshot, page-info, and PDF tools for AI agents. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots. See ScreenshotNeo and its API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

To capture one page from the command line, replace the target URL with your page’s URL and provide your API key. The response image can then be renamed or saved under a URL-derived filename by your batch script.

Rank #4
Sale
SANDISK 1TB Extreme Portable SSD, Up to 2000MB/s Transfer Speeds-New Model | External Solid State Drive, IP65 Water & Dust Resistant, Up to 3M Drop Protection, 256-bit AES Encryption, USB-C 3.2 Gen 2
  • NEARLY 2X FASTER THAN OUR PREVIOUS GENERATION(8) – move 1,000 high-res photos in under 60 seconds(6) with up to 2000MB/s transfer speeds(2).
  • IP65 RATING AND UP TO 3M DROP PROTECTION(3) – protects against spills and drops.
  • POCKET-SIZED – fits easily in pockets and small bags.
  • SPACE TO OWN YOUR AI CONTENT – speed and capacity to download your high-res clips and photo edits.
  • 256-BIT AES ENCRYPTION(4) – helps keep private files secure with password protection.

Sign up for 1,000 free screenshots a month, with no card required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use Playwright CLI for a one-off

For an occasional capture, Playwright CLI accepts a custom filename; without --filename, its documented default is timestamp-based. Use --full-page when you need the full scrollable page. The CLI screenshot documentation lists the current command options. For a list of URLs with URL-based filenames and per-page error handling, a script or shot-scraper YAML configuration avoids manually issuing and renaming each capture.

Common troubleshooting

A page times out or captures blank

Sites may take longer to render than the default navigation timeout or require a later page state. Increase the timeout if appropriate and wait for a meaningful selector rather than adding the same arbitrary delay to every URL. Log the error and status in the manifest to identify pages that need a different readiness condition.

Best Value
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Two pages produce the same filename

Sanitization can collapse distinct paths into the same readable slug. Add a short hash of the complete input URL, including query string, as in the Playwright example; retain the original URL in the manifest.

The screenshot differs between runs

Standardize browser and capture settings and account for dynamic page elements. Operating system, browser version, hardware, and headless mode can affect rendering, as described in Playwright’s visual comparison guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The image is much larger than expected

A full-page screenshot can be very tall, while device-pixel scale can increase output dimensions on high-DPI devices. Use viewport capture or CSS-pixel scale when those better match the job.

Frequently Asked Questions

How do I save a screenshot with the page URL in the filename?

Create a filesystem-safe slug from the URL’s host and path, add a short hash to distinguish collisions, and keep the exact URL in a manifest.

How can I take screenshots of a list of URLs?

Read one URL per line into a Playwright script, or define each URL and output in shot-scraper’s multi-image YAML configuration.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

browser automationPlaywrightScreenshotNeoshot-scraperweb screenshots

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.