A sitemap XML file is a list of page addresses that a site publishes so crawlers can find its pages without following every link. Each entry holds one URL and, when the site fills it in, the date that page last changed.
The format is set out on sitemaps.org, and Google's own sitemap documentation points there for the rules. A crawler that reads a sitemap first knows which addresses the owner wants found before it fetches a single page. For a web scraping job that means a ready list of addresses to start from. The list can still leave pages out, and the run further down reads a file that does.
What the file contains
This clip reads a small sitemap, a real one and a sitemap index, then shows where to find the file.
Read the transcript
What a sitemap file holds. A list of page addresses a site publishes, and the two counts worth taking.
Each entry needs a loc with the address. A lastmod date is optional. /guide/install/ has lastmod 2026-09-02. /guide/upgrade/ has no lastmod. 2 URLs listed. 1 carries a lastmod.
One real file lists 2 URLs, both dated. They are versions of the docs, not pages. The file at https://requests.readthedocs.io/sitemap.xml is a sitemap. /en/latest/ has lastmod 2026-10-26. /en/stable/ has lastmod 2026-05-14. 2 URLs listed. 2 carry a lastmod.
Every address sits on the file's host and scheme, under its path. Scope: one file. host: Same host and scheme. path: /docs/sitemap.xml: /docs/ only.
A larger site splits the list and names the parts in an index. Each file: sitemap.xml or .xml.gz. URLs: At most 50,000. size: At most 50MB, unzipped.
An index names child files. With no dates, a crawler asks for both each time. The file at https://www.rfc-editor.org/sitemap.xml is a sitemap index. /sitemap-1.xml has no lastmod. /sitemap-2.xml has no lastmod. 2 child files. 0 carry a lastmod. 2 to fetch each time.
Find the file on a Sitemap line in robots.txt. It grants no permission. Before you fetch: GET /robots.txt. robots: A Sitemap line names it. root: Else try /sitemap.xml. rules: Check each address.
Read the full page. The page is at spider.cloud/learn/sitemaps.
The protocol asks for very little. A sitemap opens with a <urlset> tag that names the namespace, holds one <url> block for each page, and gives each block a <loc> with the address. That is the whole required part. The sitemaps.org page then adds: "All other tags are optional. Support for these optional tags may vary among search engines."
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://docs.example.com/guide/install/</loc>
<lastmod>2026-09-02</lastmod>
</url>
<url>
<loc>https://docs.example.com/guide/upgrade/</loc>
</url>
</urlset>This sample lists two pages. Only the first one says when it changed.
There are three optional tags.
<lastmod>is the date the page was last modified, either as a plain day or with a time. sitemaps.org is strict about what that date means: "the date must be set to the date the linked page was last modified, not when the sitemap is generated."<changefreq>is a guess at how often the page changes, fromalwaystonever.<priority>ranks a page against the other pages on the same site, from 0.0 to 1.0.
The date is the tag worth reading. Google's sitemap documentation says it ignores the other two, and it treats the date with care. It uses the value "if it's consistently and verifiably (for example by comparing to the last modification of the page) accurate." So a date that changes every time the file is rebuilt, while the page stays the same, teaches a reader to stop trusting it.
Every address in one file sits on one host and uses one scheme. In the protocol's words, "all URLs listed in the Sitemap must use the same protocol" and reside on the same host as the file. A sitemap at https://docs.example.com/ cannot list pages on https://blog.example.com/. The path matters too. A file at /docs/sitemap.xml may list only addresses under /docs/.
When one file is not enough
A single sitemap has a ceiling. sitemaps.org says each file "must have no more than 50,000 URLs and must be no larger than 50MB (52,428,800 bytes)." Many sites gzip the file and name it sitemap.xml.gz. The 50MB limit applies to the file after you unzip it. A larger site splits its list into several files and publishes a sitemap index that points at them.
An index looks like a sitemap with different tag names: <sitemapindex> instead of <urlset>, and <sitemap> blocks instead of <url> blocks. Each block has a <loc> with the address of one child file and may have a <lastmod>. That date belongs to the child file, not to its pages. The protocol says the index date "does not correspond to the time that any of the pages listed in that Sitemap were changed."
Reading an index is two steps. Fetch the index, then fetch each child file it names. A child file that has not changed since your last visit can be skipped, if the index gives a date you trust.
Where to look for one
Most sites put the file at the root, as /sitemap.xml. The surer route is the site's robots.txt, which can name the file on a Sitemap line. The protocol says the line "is independent of the user-agent line, so it doesn't matter where you place it in your file", and a robots.txt file may hold more than one. The page on how to read robots.txt covers the rest of that file.
A sitemap grants no permission. It lists what the owner would like found. What a crawler may fetch is still set by robots.txt, and sitemaps.org says so itself: "To tell search engines the content you don't want indexed, use a robots.txt file or robots meta tag." Check every address in the list against the robots.txt rules before you request it.
One real file, counted
Requests, a Python library, keeps its documentation on Read the Docs, and the sitemap sits at the usual root address. The call below fetches that file raw through the Spider API and names its client in user_agent. Your key goes in SPIDER_API_KEY.
curl -s https://api.spider.cloud/scrape \
-H "Authorization: Bearer $SPIDER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://requests.readthedocs.io/sitemap.xml", "request": "http", "return_format": "raw", "user_agent": "examplebot/1.0 (+https://example.com/bot; bot@example.com)"}'Our copy is from 2026-11-20 at 17:27 UTC. The page status was 200 and the answer took 1.4 seconds. These are the lines of the content field that hold entries. We left out a comment block and the blank lines between tags.
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://requests.readthedocs.io/en/latest/</loc>
<lastmod>2026-10-26T17:14:45.134020+00:00</lastmod>
</url>
<url>
<loc>https://requests.readthedocs.io/en/stable/</loc>
<lastmod>2026-05-14T19:39:56.057617+00:00</lastmod>
</url>
</urlset>Counted, the file lists 2 URLs, and both carry a last modified date. Neither has <changefreq> or <priority>.
Both addresses end at a version name, latest and stable. The file lists versions of the docs, not pages. Read the Docs, which generates it, says in its documentation: "The sitemap includes public and not hidden versions of your documentation and when they were last updated." So the file tells a crawler where each version starts and when it was last updated. To reach the pages inside a version, the crawler still has to follow links from that starting address.
We also asked for the sitemap at https://www.rfc-editor.org/sitemap.xml with the same request and only the url changed, at 17:28 UTC on the same day. It came back as an index, cut here to its entries:
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://www.rfc-editor.org/sitemap-1.xml</loc></sitemap><sitemap><loc>https://www.rfc-editor.org/sitemap-2.xml</loc></sitemap></sitemapindex>That index names 2 child files and gives neither a date. A crawler that wants to know what changed there has to ask for both files each time, and a conditional request can make an unchanged one cheap.
What the count tells you
The two counts, URLs listed and URLs with a date, answer two separate questions.
The first is how much the sitemap covers. Compare its URL count with what you find by following links. When the sitemap lists far fewer, as with Requests, treat it as a set of starting points. When it lists more, it may be the only way to reach pages that nothing links to.
The second is how cheaply you can stay current. If most entries carry a date you have checked against the pages, you can fetch only the addresses whose date moved since your last pass. If few carry one, or the dates turn out not to match the pages, you are back to fetching everything.
A large sitemap is also an easy way to send too many requests at once. A file with 50,000 addresses on one host is 50,000 requests to the same server. Keep a steady pace, and keep to any Crawl-delay line the site's robots.txt sets.
Do this, avoid this
Do this
- Look for a Sitemap line in robots.txt before guessing at /sitemap.xml.
- Count the URLs in the file and the share that carry a lastmod date before you plan a crawl.
- Check a few lastmod dates against the pages they describe before you rely on them.
- Check each listed address against the robots.txt rules before you request it.
- Read an index in two steps, and skip a child file whose date has not moved, if you trust that date.
Avoid this
- Assuming the file lists every page the site has.
- Reading a lastmod date on an index entry as the date its pages changed.
- Expecting a file under /docs/ to list pages outside that path.
- Taking a URL's place in the sitemap as permission to fetch it.
To run the same check on a site you plan to crawl, put its robots.txt address in the request above, find the Sitemap line, then fetch the file it names. Count the URLs and the dates before you decide where the crawl starts.