TL;DR: A sitemap is a discovery input, not a complete dataset or permission to fetch every listed URL. Distinguish URL sets from indexes, parse namespaces deliberately, treat freshness metadata as a source claim, and enforce retrieval boundaries before adding targets to a collection queue.
A product category shows twenty links, but its sitemap lists thousands of product addresses. Web scraping sitemaps can help you discover that larger candidate set without navigating every menu. The important distinction is that a sitemap supplies locations and limited metadata; it does not supply the product records themselves or guarantee that every listed page is available.
Link following fills gaps when a sitemap is missing or incomplete, which our guide to web crawling with Python works through.
Sitemap-based discovery also changes the trust boundary. XML files and the URLs inside them are external input. A parser may recognize a document successfully while the resulting address is outside your collection scope. An index can point to many documents, and compressed files can expand far beyond their transferred size.
This guide separates discovery, validation, and collection. You will inspect the two main XML shapes, run a local Python fixture, define traversal limits, and decide how to use lastmod without treating it as proof of change. The exercise uses fictional documents held in memory and makes no network requests. Apply the same reasoning to an approved site before adding its discovered pages to a real fetch queue.




