
How to screenshot every page in your sitemap automatically
How to Screenshot Every Page in Your Sitemap Automatically Visual audits, site archives, client deliverables, pre-migration snapshots — all require screenshots of every page on a site. Doing it manually takes hours. Doing it with Puppeteer means managing a browser pool and handling concurrency yourself. Here's a script that parses your sitemap.xml and captures every URL with controlled concurrency and automatic retry. Basic sitemap crawler import fs from " fs/promises " ; import path from " path " ; const PAGEBOLT_API_KEY = process . env . PAGEBOLT_API_KEY ; const SITEMAP_URL = process . env . SITEMAP_URL || " https://yoursite.com/sitemap.xml " ; const OUTPUT_DIR = " screenshots " ; const CONCURRENCY = 3 ; // parallel requests const DELAY_MS = 500 ; // between batches async function fetchSitemap ( url ) { const res = await fetch ( url ); const xml = await res . text (); // Extract all <loc> URLs const urls = [... xml . matchAll ( /<loc> ([^ < ] + ) < \/ loc>/g )]. map (( m ) => m [ 1 ]
Continue reading on Dev.to Webdev
Opens in a new tab



