DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk7 min

How to Screenshot Multiple URLs with Chrome DevTools Protocol

Use Node.js and Chrome DevTools Protocol to visit a list of URLs, wait for each page, and save distinct viewport screenshots with failure handling.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To screenshot multiple URLs with Chrome DevTools Protocol (CDP), connect to a running Chrome instance, navigate to each URL, wait for the page condition you care about, capture the page with Page.captureScreenshot, and save each result under a unique filename. The example below uses Node.js and the lower-level chrome-remote-interface library; Puppeteer is a simpler alternative when you want it to launch and manage the browser.

What the workflow does

CDP is a JSON-based protocol for instrumenting and inspecting Chromium-based browsers. Its Page domain provides Page.navigate and Page.captureScreenshot, the two commands at the center of a batch capture. A reliable script adds the work around those commands: starting or connecting to Chrome, choosing when a page is ready, naming output files safely, recording failures, and cleaning up browser resources.

The protocol reference has a frequently changing tip-of-tree version as well as a stable subset, and tip-of-tree is not guaranteed to remain backwards-compatible. Check the protocol supported by the Chrome build you actually automate before depending on parameters or experimental commands. Chrome DevTools Protocol documentation

Run a multi-URL capture with raw CDP

This Node.js example connects to Chrome through chrome-remote-interface. It expects Chrome to be started separately and its remote-debugging endpoint to be available on port 9222. The script creates one tab, visits the URLs in order, waits for the load event, captures each viewport as PNG, and writes an indexed filename so duplicate paths do not overwrite each other.

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.
#1 Best Overall

1. Start Chrome with remote debugging

Start a separate Chrome process with a remote debugging port. Use an isolated profile directory for automated work, rather than exposing a profile containing your personal signed-in sessions.

google-chrome --headless --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-cdp-profile

The executable name differs by operating system and installation. Chrome documents the --remote-debugging-port=9222 option in its Headless guide; the exact launch mechanism and process cleanup are your responsibility when using this lower-level library. Chrome Headless documentation

2. Install the Node dependency

In a working directory, initialize a Node project if needed, then install chrome-remote-interface:

Rank #2
Dell Latitude 3190 11.6" HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
  • 1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core
  • 4GB DDR4 System Memory; 128GB Solid State Drive
  • 11.6" HD (1366 x 768) Multi-Touch Display
  • Combo headphone/microphone jack - Noble Wedge Lock slot - HDMI; 2 USB 3.1 Gen 1
  • Windows 11 Pro
npm init -y
npm install chrome-remote-interface

Save the following as capture.mjs. It accepts URLs as command-line arguments, writes PNG screenshots to screenshots/, and reports individual navigation or capture failures without silently treating them as successful images.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import CDP from 'chrome-remote-interface';
import fs from 'node:fs/promises';
import path from 'node:path';

const urls = process.argv.slice(2);
if (urls.length === 0) {
  console.error('Usage: node capture.mjs <url> [url ...]');
  process.exit(2);
}

// Accept only web URLs. Add a host allowlist as well if these URLs are untrusted.
for (const value of urls) {
  let parsed;
  try {
    parsed = new URL(value);
  } catch {
    throw new Error(`Invalid URL: ${value}`);
  }
  if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
    throw new Error(`Only http and https URLs are allowed: ${value}`);
  }
}

const outputDir = path.resolve('screenshots');
await fs.mkdir(outputDir, { recursive: true });

let client;
let targetId;
const failures = [];

try {
  // Create a fresh tab on the already-running Chrome instance.
  const target = await CDP.New('about:blank');
  targetId = target.id;
  client = await CDP({ target: targetId });

  const { Page } = client;
  await Page.enable();

  for (let i = 0; i < urls.length; i++) {
    const url = urls[i];
    const label = String(i + 1).padStart(3, '0');
    const pageUrl = new URL(url);
    const slug = `${pageUrl.hostname}${pageUrl.pathname}`
      .replace(/[^a-z0-9]+/gi, '-')
      .replace(/^-+|-+$/g, '')
      .slice(0, 70) || 'page';
    const file = path.join(outputDir, `${label}-${slug}.png`);

    try {
      // Install the event listener before navigation to avoid missing a fast load.
      const loaded = new Promise((resolve) => {
        Page.loadEventFired(() => resolve());
      });
      await Page.navigate({ url });
      await loaded;

      const { data } = await Page.captureScreenshot({ format: 'png' });
      await fs.writeFile(file, Buffer.from(data, 'base64'));
      console.log(`Saved ${file}`);
    } catch (error) {
      failures.push({ url, error: error.message });
      console.error(`Failed ${url}: ${error.message}`);
    }
  }
} finally {
  if (client) await client.close();
  if (targetId) {
    try {
      await CDP.Close({ id: targetId });
    } catch {
      // Chrome may already have closed the target.
    }
  }
}

if (failures.length) {
  console.error(`${failures.length} URL(s) failed.`);
  process.exitCode = 1;
}

3. Run it

node capture.mjs https://example.com https://developer.chrome.com/docs/chromium/headless

Each screenshot is a viewport capture in the current page dimensions. This example uses Page.loadEventFired as its readiness rule; it does not guarantee that every image, font, animation, or client-rendered component has finished appearing. For a site whose content arrives after the load event, wait for a selector or an application-specific ready signal before calling Page.captureScreenshot.

Choose a readiness condition deliberately

Load event

Page.loadEventFired is useful when the page’s main load event is an adequate threshold. It is an event boundary, not proof that all visually relevant content has settled. The event listener should be registered before navigation so a fast-loading page cannot fire before the script starts waiting.

Rank #3
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
  • 256 GB SSD of storage.
  • Multitasking is easy with 16GB of RAM
  • Equipped with a blazing fast Core i5 2.00 GHz processor.

Network idle

Puppeteer’s documented screenshot example uses waitUntil: 'networkidle2'. This waits for a network-activity condition, but should not be treated as a universal visual-completeness guarantee; persistent requests and late JavaScript rendering can make the condition unsuitable for some sites. Puppeteer screenshot guide

Selector or application signal

For a page where a specific component matters, wait for that component to exist or become visible, or use an application-provided signal that means the desired content is ready. This is usually more meaningful than a fixed delay. If a capture depends on lazy-loaded images, the script may also need to scroll through the page before capturing and then wait for the images to load.

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

Viewport screenshots, full-page captures, and output names

Page.captureScreenshot captures the current visible viewport by default. A long document is not automatically included in full. Full-page capture needs additional steps, and the exact protocol options should be checked against the Chrome version in use. Chrome’s Headless CLI guide likewise notes that full-page screenshots involve extra steps.

Rank #4
15.6 Inch Laptop Computer, N4020, 4GB DDR4 RAM, 128GB eMMC,with Windows 11
  • EFFORTLESS EVERYDAY PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 Home system, delivering reliable, low-power efficiency for daily tasks like document editing, email, online classes, and web browsing
  • 15.6-INCH FULL HD DISPLAY: Enjoy immersive visuals on the 15.6" FHD (1920x1080) anti-glare screen with micro-edge bezels. Delivers clear details and comfortable viewing for long study sessions, working on spreadsheets, and video playback
  • RESPONSIVE MULTITASKING & STORAGE: Built with 4GB LPDDR4 RAM and 128GB eMMC storage for smooth daily essential use. Expand your storage by up to 1TB via the integrated TF card slot to easily store movies, photos, and working files
  • ADVANCED CONNECTIVITY: Outfitted with 2x Full-Featured Type-C ports for data transfer, fast charging, and dual-monitor output, alongside 2x USB 3.2 Gen1 ports and a 3.5mm audio jack for complete peripheral compatibility
  • LIGHTWEIGHT & SILENT OPERATION: Slim and portable for effortless travel or commuting. Features a 1MP HD webcam for remote meetings, 38Wh battery with 45W Type-C fast charging, and a fanless silent design for peaceful work environments.

The example combines a zero-padded index with a hostname/path slug. The index prevents collisions when two input URLs normalize to the same slug; sanitizing the slug avoids writing arbitrary URL characters directly into a filesystem path. If input URLs can be controlled by someone else, validate both the scheme and permitted hosts before visiting them: a browser automation process makes requests using the network access available to its host.

Alternative approaches

Approach Best fit Trade-off
Raw CDP Precise control over protocol commands, events, and browser targets You handle connection, browser launch, readiness, result handling, and cleanup; tip-of-tree protocol details can change.
chrome-remote-interface Node access close to CDP Chrome’s guide says the library does not launch Chrome; process management is separate.
Puppeteer A concise Node workflow with browser launch and screenshot helpers It abstracts CDP details; use its current API documentation and pin compatible versions for repeatable automation.
Chrome Headless CLI A one-off page capture or viewport-size example The documented --screenshot command writes screenshot.png in the current working directory; a URL loop and distinct filenames still need scripting, and full-page capture needs extra work.

Chrome describes Puppeteer as a JavaScript library that automates Chrome and Firefox over CDP and WebDriver BiDi. Its screenshot guide demonstrates launching a browser, navigating with a wait condition, saving a screenshot to a path, and closing the browser. Puppeteer documentation Chrome’s Headless guide also describes using chrome-remote-interface for lower-level protocol work. Chrome Headless documentation

Reliability, speed, and cost considerations

  • Batch size and concurrency: the example processes URLs sequentially, which is simpler to debug and avoids creating many simultaneous page loads. If you add concurrency, bound it and monitor browser memory and target cleanup.
  • Timeouts: a page may never meet the chosen readiness condition. Production scripts should add a timeout for each navigation/wait and record timed-out URLs for retry or review.
  • Retries: retry transient failures selectively, not in an unbounded loop. Preserve the failed URL and error in a log so a missing screenshot cannot be mistaken for a successful capture.
  • Reproducibility: pin the Node library version and run a known Chrome build; CDP protocol support depends on the browser being automated.
  • Cost: local CDP does not impose a per-screenshot service fee, but it uses your compute, browser maintenance, storage, and time to handle failures. Remote hosted browser or screenshot services may price differently.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

  • Cannot connect to Chrome: confirm Chrome started with --remote-debugging-port=9222, that the port is reachable from the Node process, and that a conflicting process is not already using it.
  • Screenshot file is missing or zero bytes: check the script’s output directory permissions and whether the capture threw an error; the example prints the destination only after writing succeeds.
  • Screenshot shows an incomplete page: replace the load-event wait with the condition that represents readiness for that site, such as a visible selector or application signal.
  • Two captures overwrite each other: retain a unique index or another collision-proof identifier in each filename; URL paths alone may normalize to the same slug.
  • Protocol method or parameter fails: compare the command against the protocol supported by the installed Chrome version rather than assuming the mutable tip-of-tree reference matches it.
  • Chrome remains running after a failure: keep target closure and client disconnection in a finally path, and separately stop the Chrome process that your launch mechanism created.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. A single GET request can return a PNG, JPEG, WebP, or PDF. Its screenshot endpoint accepts a URL and capture options; see the API documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage
  • WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
  • 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
  • 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
  • CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
  • LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan.

Frequently Asked Questions

Can I use CDP to capture a screenshot for every URL in a text file?

Yes. Read the file into a URL array and pass that array through the same navigation-and-save loop; keep filename uniqueness and per-URL error reporting.

Does a CDP screenshot include the whole page?

Not by default. The sample captures the current viewport; full-page capture requires additional handling.

Quick Recap

Bestseller No. 1
HP 14' HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
HP 14" HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
$249.99
Bestseller No. 2
Dell Latitude 3190 11.6' HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
Dell Latitude 3190 11.6" HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core; 4GB DDR4 System Memory; 128GB Solid State Drive
Bestseller No. 3
Dell Latitude 5420 14' FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
256 GB SSD of storage.; Multitasking is easy with 16GB of RAM; Equipped with a blazing fast Core i5 2.00 GHz processor.
$304.99

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.

Leave a Reply

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

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

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
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.