Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon 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×
FREEDOM251

Freedom251 › Blog › JavaScript

How to Capture Full-Page Screenshots of Every URL in a Sitemap with Puppeteer

By Freedom251 Team · · 6 min read

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

To screenshot every page listed in a sitemap, first fetch and parse the sitemap (including any child sitemaps in an index), then visit each absolute page URL with Puppeteer and save page.screenshot({ fullPage: true }). Set the viewport before navigating, choose a wait condition that suits the site, and record failures per URL so one problem page does not stop the batch.

How the sitemap-to-screenshot workflow works

A sitemap is a list of URLs; it does not contain screenshots or rendered page content. The workflow has two distinct parts: extract page URLs from sitemap XML, then use a browser to render and capture each page.

As an Amazon Associate I earn from qualifying purchases.

  1. Fetch the known sitemap URL or the sitemap location published by the site.
  2. Check whether the XML root is urlset or sitemapindex. A URL set contains page entries; an index points to other sitemap files.
  3. Collect the absolute page URLs from each loc, following index entries recursively or iteratively as needed.
  4. For each page URL, set the viewport, navigate, wait for an appropriate readiness condition, and save a screenshot with fullPage: true.
  5. Keep a per-URL record of success or failure and close the browser after the batch.

The Sitemap Protocol describes the XML structure and requires UTF-8 and entity-escaped values. Use an XML parser rather than a regular expression to extract locations. [Sitemap Protocol]

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

Fetch both sitemap files and pages, including sitemap indexes

URL-set sitemap

A URL-set sitemap has a urlset root. Its url entries contain loc elements holding the page URLs to capture.

#1 Best Overall
Dell Optiplex 3060 Desktop Computer | Intel i5-8500 (3.2) | 32GB DDR4 RAM | 1TB SSD Solid State | Built in WiFi | Bluetooth | Windows 11 Professional | Home or Office PC (Renewed)
  • [INTEL POWERED CONTENT] - Built with a 8th Generation Hexa-Core Intel i5 and 32GB of DDR4 RAM; Modern, Windows 11 ready, with 4K support, Executive multitasking, media streaming and smooth, multi-tab web browsing; Perfect as an all-purpose multimedia computer; built for content creators; Plenty of RAM and Mass storage for photo and video editing powered by Intel HD 630
  • [LATEST WIRELESS TECH] - This Dell Desktop Computer easily connects to the internet through the Built In WiFi / Bluetooth
  • [SOLID STATE STORAGE] - This Dell Computer setup comes with an ultra-fast 1TB Solid State Drive (SSD); Setup as the primary boot device; Boot and load programs with lightning speed ; Additional expansion available
  • [BUY & OWN WITH CONFIDENCE] - From the world's largest Microsoft Authorized Refurbisher; Quality Guarantee and Free Tech Support; Award-winning Customer Service; | Support Sustainable Business
  • [MODERN HI-SPEED PORTS] - USB 3.0 (x4) | USB 2.0 (x4) | DisplayPort (x1) | HDMI Port (x1) | Audio Combo Jack (x1) | Audio Out (x1) | RJ-45 Ethernet (x1) | Internal SATA (x3)

Sitemap index

A sitemap index has a sitemapindex root. Each child sitemap entry has a loc pointing to another sitemap file; fetch those files and collect their page URLs. An index does not itself provide the complete page URL list unless you follow its child locations.

Google recommends fully qualified absolute URLs. Google Search Central states that a sitemap can contain up to 50,000 URLs or 50 MB uncompressed, whichever limit is reached first, and that a sitemap index can list up to 50,000 sitemap locations. These are limits per sitemap and per index, respectively; organize larger collections across multiple files and indexes. [Google Search Central: Build and submit a sitemap] [Google Search Central: Manage large sitemaps]

Capture every URL with Puppeteer

The following browser-loop pattern uses the documented Puppeteer APIs. It assumes urls is an array of absolute URLs already extracted from the sitemap files, Puppeteer is installed, and the screenshots output directory exists. This is an illustrative pattern, not a tested script or a complete sitemap parser.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Dell Optiplex 7050 SFF Desktop PC Intel i7-7700 4-Cores 3.60GHz 32GB DDR4 1TB SSD WiFi BT HDMI Duel Monitor Support Windows 11 Pro Excellent Condition(Renewed)
  • Model: Dell OptiPlex 7050 Small Form Factor (SFF)
  • Processor: Intel Core i7-7700 3.60 GHz
  • Memory: 32GB DDR4 Ram
  • Storage: 1TB Solid State Drive (SSD) Fast Boot + Storage
  • Operating System: Windows 11 Pro (64-bit)
import puppeteer from 'puppeteer';

const urls = [
  'https://example.com/',
  'https://example.com/about/',
];

const browser = await puppeteer.launch();
const results = [];

try {
  const page = await browser.newPage();
  await page.setViewport({ width: 1440, height: 900 });

  for (const [index, url] of urls.entries()) {
    const path = `screenshots/page-${index + 1}.png`;
    try {
      await page.goto(url, { waitUntil: 'networkidle2' });
      await page.screenshot({ path, fullPage: true });
      results.push({ url, path, ok: true });
    } catch (error) {
      console.error(`Failed to capture ${url}`, error);
      results.push({ url, ok: false, error: String(error) });
    }
  }
} finally {
  await browser.close();
}

console.log(results);

Puppeteer’s guide demonstrates page.goto with waitUntil: 'networkidle2' and then a screenshot; the screenshot reference identifies Page.screenshot() as the capture method. [Puppeteer screenshot guide] [Puppeteer Page.screenshot API]

Set the viewport before navigation

The viewport controls the responsive layout you capture. Set it before page.goto so the page renders at the intended width from the start. Puppeteer notes that viewport changes can trigger a reload in certain mobile or touch configurations. [Puppeteer Page.setViewport API]

Use unique filenames

The example uses a sequence number to avoid overwriting files when different URLs have similar paths. For repeatable runs, consider a stable filename derived from the URL, but sanitize it for filesystem use and account for duplicate or very long paths.

Rank #3
Sale
HP All-in-OneDesktop Computer, 16GB DDR5 RAM, Intel Quad-Cores, 128GB SSD, WiFi6, Keyboard & Mouse, Windows 11
  • IMMERSIVE 24 INCH DISPLAY: Experience stunning clarity on a Full HD IPS screen with ultra-thin bezels, offering a 90% screen-to-body ratio that makes everything from spreadsheets to streaming come alive with vibrant colors and crisp details.
  • POWERFUL INTEL PROCESSING: Tackle demanding tasks with ease thanks to the Intel processor and 16GB of high-speed memory, delivering smooth performance whether you're multitasking between applications or running productivity software.
  • GENEROUS STORAGE: Store all your important files, photos, and programs with blazing-fast solid state drive technology that ensures quick boot times, rapid file access, and plenty of space for your digital life.
  • ENHANCED PRIVACY AND COLLABORATION: Work confidently with the pop-up privacy camera that tucks away when not in use, plus dual microphones with noise reduction for crystal-clear video calls that keep you connected professionally.
  • ECO-CONSCIOUS DESIGN: Feel good about your purchase with an EPEAT Gold registered and ENERGY STAR certified computer that combines premium performance with responsible environmental manufacturing practices.

Handle errors without losing the batch

The inner try/catch logs the failing URL and continues to the next one. Retain the result records or write them to a file so you can retry failures without recapturing every successful page.

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

Choose a readiness condition that fits the site

networkidle2 is an example, not a guarantee that all visible content is ready. Pages with continuous network activity may never reach network idle; other pages may render important content after navigation has technically completed.

  • Use a navigation readiness condition appropriate to the site rather than assuming one setting fits every page.
  • For script-driven content, wait for a selector that indicates the content you need is present, or use a deliberate delay when the page has a known delayed-rendering behavior.
  • For pages that keep making requests, avoid relying exclusively on network-idle waiting; use a more suitable navigation condition and an explicit page-specific readiness check.
  • For authenticated or access-controlled pages, ensure the browser context has the required session state before navigating.

Puppeteer’s guide shows the navigation-and-screenshot pattern, but readiness remains site-dependent. [Puppeteer screenshot guide]

Rank #4
Dell Optiplex 3050 SFF Desktop Computer PC, Intel Quad Core i5-6500 up to 3.6GHz, 16GB DDR4, 256GB SSD, WiFi, 4K Support, DP, HDMI, Windows 11 Pro 64 Bit (Renewed)
  • This Certified Refurbished product is tested and certified to look and work like new. The refurbishing process includes functionality testing, basic cleaning, inspection, and repackaging. The product ships with all relevant accessories, a minimum 90-day warranty, and may arrive in a generic box. Only select sellers who maintain a high-performance bar may offer Certified Refurbished products on Amazon.com.
  • Dell Optiplex 3050 SFF Desktop computer PC, Intel Quad Core i5-6500 up to 3.6GHz, 16GB DDR4, 256GB SSD
  • Includes: USB Keyboard & Mouse, USB WiFi adapter, Microsoft office 30 days free trail.
  • Port: Front: USB 3.0(2), USB 2.0(2); Rear: DP, HDMI, USB 3.0(2), USB 2.0(2), RJ-45.
  • Support 4K (3840x2160) Dual display, makes it easy to connect two monitors at the same time, and you can expand working Windows, mirror content, or expand a single window across multiple monitors.

Full-page capture, lazy content, and very tall pages

The screenshot option fullPage defaults to false; set it to true to request a screenshot of the full page. [Puppeteer ScreenshotOptions API]

Do not assume that one full-page capture will include content that loads only after scrolling, or that extremely tall pages will behave identically across sites. The cited API reference does not establish a universal height limit or guarantee lazy-loaded content. Inspect output from unusually long pages for missing sections, clipping, or unexpected layout changes. If the target relies on scroll-triggered content, use a site-specific preparation step to reveal and load that content before capture, then verify the result.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Scale the batch without losing track of results

Every URL requires browser navigation and image output, so a large sitemap can consume substantial time, memory, and disk space. No universal runtime or storage figure follows from the sitemap limits. Keep the job manageable and observable:

Best Value
Dell Windows 11 Desktop Computer OptiPlex 5060 | Intel Core i5-8500 Six Core (4.3GHz Turbo) | 16GB DDR4 RAM | 500GB SSD Solid State + 1TB HDD | WiFi + Bluetooth | Home or Office PC (Renewed)
  • Connectivity: Includes WiFi, Bluetooth, and LAN for wireless and wired connections
  • Memory: Features 16GB DDR4 RAM for smooth multitasking and performance
  • Storage: Combines 500GB SSD and 1TB HDD for ample storage space
  • Graphics: Integrated Intel UHD Graphics 630 for crisp visuals and video playback
  • Design: Sleek desktop tower with black color and slim profile for modern look
  • Start with a small sample to validate the viewport, wait condition, naming scheme, and output.
  • Use a deliberate concurrency limit if you parallelize; unbounded browser work can exhaust available resources.
  • Store the URL, output path, and error status for each attempt so failures can be retried selectively.
  • Split sitemap collections in line with the per-file and index limits, and process them in batches if necessary.
  • Review representative screenshots from different page types, especially responsive layouts and pages with long or lazy-loaded content.

Troubleshooting common capture problems

  • The script never reaches the screenshot call: a page may keep making network requests, so the chosen network-idle condition is not suitable. Select an appropriate navigation condition and wait for a page-specific readiness signal.
  • The screenshot is blank or content is missing: verify the URL and access requirements, then check whether the content appears only after scripts run, a selector appears, or the page is scrolled. Inspect the rendered result rather than assuming navigation completion means content readiness.
  • Only the initial viewport appears: confirm the screenshot call includes fullPage: true; the option defaults to false.
  • Some pages overwrite other images: use unique output paths, such as a sequence number or a sanitized URL-derived name.
  • A sitemap parser returns no URLs: check whether the file is a sitemap index rather than a URL set, follow child sitemap locations, and parse XML with a real parser. Sitemap values must follow the protocol’s UTF-8 and entity-escaping requirements.
  • A large sitemap cannot be represented by one file: split it across sitemap files and use an index; Google documents the 50,000-URL or 50 MB uncompressed sitemap limit and the 50,000-location index limit. [Google Search Central: Build and submit a sitemap] [Google Search Central: Manage large sitemaps]

Or skip the browser setup

If you want to capture pages without managing a Puppeteer browser loop, ScreenshotNeo accepts a URL in one API request and can return an image or PDF. For example, capture a sitemap URL after extracting its page URLs, calling once per page:

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

See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free.

Frequently Asked Questions

Can Puppeteer capture every page in a sitemap automatically?

It can capture each page after your script extracts the page URLs and loops over them; Puppeteer does not parse the sitemap as part of the screenshot call.

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

Does a sitemap index contain the page URLs?

An index points to child sitemap files. Fetch those files and collect their page URLs before capturing.

Does fullPage capture guarantee lazy-loaded content?

No universal guarantee is established by the screenshot API reference. Inspect long pages and prepare scroll-triggered content as needed.

Quick Recap

Bestseller No. 2
Dell Optiplex 7050 SFF Desktop PC Intel i7-7700 4-Cores 3.60GHz 32GB DDR4 1TB SSD WiFi BT HDMI Duel Monitor Support Windows 11 Pro Excellent Condition(Renewed)
Dell Optiplex 7050 SFF Desktop PC Intel i7-7700 4-Cores 3.60GHz 32GB DDR4 1TB SSD WiFi BT HDMI Duel Monitor Support Windows 11 Pro Excellent Condition(Renewed)
Model: Dell OptiPlex 7050 Small Form Factor (SFF); Processor: Intel Core i7-7700 3.60 GHz; Memory: 32GB DDR4 Ram
$384.00
Bestseller No. 4
Dell Optiplex 3050 SFF Desktop Computer PC, Intel Quad Core i5-6500 up to 3.6GHz, 16GB DDR4, 256GB SSD, WiFi, 4K Support, DP, HDMI, Windows 11 Pro 64 Bit (Renewed)
Dell Optiplex 3050 SFF Desktop Computer PC, Intel Quad Core i5-6500 up to 3.6GHz, 16GB DDR4, 256GB SSD, WiFi, 4K Support, DP, HDMI, Windows 11 Pro 64 Bit (Renewed)
Includes: USB Keyboard & Mouse, USB WiFi adapter, Microsoft office 30 days free trail.; Port: Front: USB 3.0(2), USB 2.0(2); Rear: DP, HDMI, USB 3.0(2), USB 2.0(2), RJ-45.
$189.99
Bestseller No. 5
Dell Windows 11 Desktop Computer OptiPlex 5060 | Intel Core i5-8500 Six Core (4.3GHz Turbo) | 16GB DDR4 RAM | 500GB SSD Solid State + 1TB HDD | WiFi + Bluetooth | Home or Office PC (Renewed)
Dell Windows 11 Desktop Computer OptiPlex 5060 | Intel Core i5-8500 Six Core (4.3GHz Turbo) | 16GB DDR4 RAM | 500GB SSD Solid State + 1TB HDD | WiFi + Bluetooth | Home or Office PC (Renewed)
Connectivity: Includes WiFi, Bluetooth, and LAN for wireless and wired connections; Memory: Features 16GB DDR4 RAM for smooth multitasking and performance
$269.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.

JavaScriptPuppeteerSitemapsWeb developmentwebsite screenshots

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.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.