Sitemap.xml vs website mapping vs crawling A Spidra technical guide lays out a decision tree for choosing between reading a sitemap.xml file, mapping a site's URLs, and crawling its pages, noting that sitemap reading is free via one request per file while mapping costs 1 credit per map and crawling costs 1 credit per page returned. The guide includes a Python parser that reads Sitemap lines from robots.txt, falls back to /sitemap.xml and /sitemap_index.xml, follows index files, decompresses gzip, and caps child sitemaps with a max_children setting. It recommends sitemaps when only published URLs are needed, mapping when the sitemap is insufficient, and crawling when page content is required. You need the pages of a website, but you don't know its URLs yet. On sitemap vs crawl, the short answer is this. Read the sitemap when you only need the URLs a site chooses to publish. Use Map when you need the site's URLs and the sitemap isn't enough. Use Crawl https://spidra.io/ai-crawler when you need the pages themselves and can describe them. This post gives you a decision tree, and shows what each method returns on real sites with code you can repeat. What each method gives you All three discover pages, but they answer different questions: | | Sitemap.xml | Map | Crawl | |---|---|---|---| | Finds | The URLs the site chooses to list | URLs from the sitemap and from the site's links | Pages that match a description, found by following links | | Returns | URLs, sometimes dates | URLs with the link text they were found under | Each page's content as Markdown, and extracted data if you ask | | Reads page content | No | No | Yes | | Cost | Free, your own requests | 1 credit per map | 1 credit per page returned | Read the sitemap yourself A sitemap is a file the site publishes, so reading it is free and takes one request per file. The parser below reads the Sitemap: lines in robots.txt, falls back to /sitemap.xml and /sitemap index.xml , follows index files and decompresses gzip. max children caps how many child files it opens from an index. Install requests and start with the file handling: python sitemap urls.py import gzip import re import xml.etree.ElementTree as ET from dataclasses import dataclass, field import requests HEADERS = {"User-Agent": "sitemap-reader research script "} def fetch url : response = requests.get url, headers=HEADERS, timeout=30 response.raise for status body = response.content return gzip.decompress body if body :2 == b"\x1f\x8b" else body @dataclass class Sitemaps: urls: list = field default factory=list url, lastmod or None read: int = 0 sitemap files fetched skipped: int = 0 child sitemaps left unread because of max children problems: list = field default factory=list files that failed, with the reason def locations site, get=fetch : """Sitemap files the site announces in robots.txt, else the two usual paths. Returns urls, announced .""" try: robots = get f"{site}/robots.txt" .decode "utf-8", "replace" found = re.findall r" ?im ^\s sitemap:\s \S+ ", robots except Exception: found = return found, True if found else f"{site}/sitemap.xml", f"{site}/sitemap index.xml" , False sitemap urls walks the files, keeps every