# Sitemap Extractor — sitemap parser, URL list and status codes (`chasen/sitemap-extractor`) Actor

Point it at a domain or a sitemap URL and get every URL the site publishes in its XML sitemap, as structured rows with optional HTTP status codes. A sitemap parser and sitemap index follower, not a web crawler: it reads published sitemap files and probes URL status only. Nine inputs, not thirty.

- **URL**: https://apify.com/chasen/sitemap-extractor.md
- **Developed by:** [jun cai](https://apify.com/chasen) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Sitemap Extractor

**A sitemap parser that returns a clean URL list — not a web crawler wearing a sitemap costume.**

Give it a domain or an XML sitemap URL and it finds the site's sitemap, follows any `<sitemapindex>` files, and returns every URL the site publishes as structured rows. Tick one box and it probes each URL's HTTP **status codes** too.

### Introduction

Most tools called "sitemap extractor" are general-purpose crawlers with a sitemap-shaped front door. They hand you thirty knobs, ask you to write JavaScript, require a proxy, and fail about one run in five.

This one does exactly one job: **read the sitemap files a website has already published, and tell you what is in them.**

- **Sitemap discovery.** Point at `example.com` and it reads `robots.txt`, then tries the usual paths — `/sitemap.xml`, `/sitemap_index.xml`, `/wp-sitemap.xml`, and the rest — until it finds one.
- **Sitemap index support.** `<sitemapindex>` files are followed recursively. WordPress publishes an index of indexes; depth 3 covers it.
- **Every sitemap flavour.** XML urlsets, sitemap indexes, Google News and image extensions, plain-text sitemap lists, RSS and Atom. Missing XML namespaces and arbitrary tag prefixes are handled, because old plugins produce both. Malformed XML is salvaged rather than thrown away: a sitemap with one bare `&` in it still yields the other 399 URLs.
- **Status codes, done properly.** `HEAD` first, falling back to `GET` only where a server actually refuses `HEAD` (405/501). Page bodies are never read or stored — this is a status check, not a content scraper.
- **`<lastmod>` kept verbatim.** Real sitemaps contain `2023`, `2023-04`, `+0800` without a colon, RFC822, and dates that do not exist. The raw value is always preserved, with a best-effort ISO parse alongside it. A date that will not parse never drops the row.
- **Typed failures.** Every non-success row carries an `errorType` from a fixed enum (`http_error`, `timeout`, `dns`, `blocked`, `html_challenge`, `truncated`, `skipped_budget`, …) so you can filter and count them. Free-text errors cannot be filtered, which is why tools that only ship free-text errors are impossible to monitor.

Nine inputs. That is deliberate: the competitor's thirty knobs are mostly ways to configure a crawler you did not want.

**What it does not do.** It does not render JavaScript. It does not follow links inside pages. It does not rotate proxies, spoof a browser, or attempt to get past a block — if a target answers `403` or serves a bot-challenge page, the run records it and moves on. It does not read page content, touch logins or paywalls, or collect personal data. It only reads sitemap files that are already public and checks the status of URLs the site itself published.

### Tutorial

#### 1. The simplest run

Set **Start URLs** to a domain and press **Start**:

```
startUrls: [{ "url": "https://www.apify.com" }]
```

Output is one row per URL found in the site's sitemap.

#### 2. You already have a sitemap URL

Paste it directly. It is used as the seed instead of being discovered:

```
startUrls: [{ "url": "https://www.apify.com/sitemap.xml" }]
```

#### 3. Turn on status codes

**Check status codes** is on by default. Every row then gains `statusCode` and `contentType`. Turn it off to get the URL list alone — the run becomes much faster and much cheaper, because the status probe is where nearly all of the requests go.

#### 4. Bound the work, not just the output

Two separate limits, and the difference matters:

| Input | Bounds | Default |
|---|---|---|
| **Max URLs** (`maxUrls`) | how many rows come back | 1 000 |
| **Max total requests** (`maxRequestsTotal`) | how much work the run may do | 20 000 |

A single sitemap index can legally reference 50 000 child sitemaps, and the status check then roughly doubles the request count. `maxUrls` alone would not stop that. When the request budget runs out, the run ends cleanly: `truncated: true` in the summary, the untouched URLs marked `skipped_budget`. It never fails silently and never pretends to be complete.

**Max total charge (USD)** is a third guard, this one on your bill: the run stops pushing rows before it charges more than you asked.

#### 5. Reading the output

Each row in the dataset is one URL:

```json
{
  "url": "https://example.com/products/42",
  "normalizedUrl": "https://example.com/products/42",
  "sourceSitemap": "https://example.com/sitemap_products_1.xml",
  "depth": 1,
  "checked": true,
  "statusCode": 200,
  "contentType": "text/html",
  "lastmodRaw": "2024-11-02T08:00:00+0000",
  "lastmodIso": "2024-11-02T08:00:00+00:00"
}
```

A field that does not apply is **absent**, not `null`. There is no
`errorType` above because that URL came back clean; a row that was never
probed carries no `statusCode` at all. Telling "no problem" apart from
"unknown" is the job of `checked` and `errorType`, so a missing key never
has to mean two things at once.

**Some rows are listed but never checked.** A sitemap often publishes URLs on a CDN or a partner host. Those are returned with `crossDomain: true` and `errorType: "cross_domain"`, and are never requested. Fetching a third party the site merely referenced is not what you asked for. `www.example.com` and `example.com` count as one site and are never marked this way; real subdomains are governed by **Include subdomains**.

The **Problems** view in the Output tab shows only rows that did not come back clean. Use it first; it is usually the fastest way to find out whether a run is worth reading.

Three records also land in the key-value store:

- `SUMMARY` — the run report: sitemaps attempted and succeeded, URLs discovered and deduped, requests and bytes spent against budget, `truncated`, `truncateReason`, and a breakdown of every `errorType`. Written even when the run is cut short or fails.
- `SITEMAPS` — one record per sitemap file attempted, including the ones that failed and why.
- `NEXT_STEP` — see Support below.

#### 6. Timings, stated honestly

Requests to any single host are paced at about 4 per second with at most 4 in flight, and `robots.txt` `Crawl-delay` is honoured if the site sets one. That cap is a compliance choice, and it is what determines the runtime — not CPU.

Two things add up: **reading the sitemaps**, which depends entirely on how many the site publishes, and **checking status**, which costs about 0.3 s per URL against a single host.

Measured on one site publishing 24 sitemap files with 3.69 million URLs listed in them, status checking **on**, on the code in this repository:

| rows returned | wall clock |
| --- | --- |
| 200 | 3 min |
| 500 | 4 min |
| 1 000 | 7 min |
| 10 000 | did not finish in 15 min — don't |

Reading those 24 sitemaps was about 2 minutes of every one of those runs, paid whether you ask for 200 rows or 10 000. A site publishing two small sitemap files is far quicker: 500 rows with status codes took 2½ minutes.

Three things worth knowing before you raise the number:

- **The run is paced, not parallelised.** 50 000 URLs on one host is a multi-hour job. That is the target's willingness to be asked, not this Actor being slow.
- **Some sites rate-limit, and that is reported honestly.** One target returned 429s; the tool backed off and marked those rows `rate_limited` rather than calling them dead links. Correct behaviour, and it takes longer.
- **`SUMMARY.truncated` is `true` whenever `maxUrls` is why you did not get every URL**, and `truncateReason` says so. The default is 1 000 rows and the example run in the console does 200. Raise `maxUrls` when you want more — but check `truncated` before concluding a site is small.

#### 7. Running it from the API

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/YOUR_USERNAME~sitemap-extractor/runs?token=YOUR_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
    "startUrls": [{ "url": "https://example.com" }],
    "checkStatusCodes": true,
    "maxUrls": 1000
  }'
```

Omit `maxUrls` and you get the same 1 000. Pass a bigger number when you want more rows — see the timings above first.

### Pricing

**This Actor is currently free.** A price will be added after it has been in the Store long enough for people to have tried it — and the price will be published in this section before it takes effect, not sprung on anyone.

The intended model is **pay per event**, charged one item per row returned (`apify-default-dataset-item`), at the low end of what sitemap extractors charge. When that lands:

- **You are charged for rows returned, not for time or compute.** A run that finds 200 URLs costs the same as any other 200-URL run.
- **A run that finds nothing costs nothing.** There is no minimum charge and no per-run fee.
- **`maxTotalChargeUsd` bounds the bill.** Set it and the run stops before exceeding it. The dataset is cut, not lost — `SUMMARY` reports `rowsDroppedForChargeLimit` so you can see exactly what was cut and why.
- **Budget exhaustion never overcharges.** When the request budget runs out, the run stops cleanly and reports it. You are not charged for work that did not happen.

Turning **Check status codes** off is the single biggest cost lever, because status probing accounts for the overwhelming majority of requests.

### Support

**Open an issue** at [github.com/Chasen1992/sitemap-extractor/issues](https://github.com/Chasen1992/sitemap-extractor/issues) — include the run URL and the `SUMMARY` record if you have one. That record is designed to make bug reports self-diagnosing.

**Want these URLs watched for changes?** The thing people most often want next is not another extraction but a *monitor*: run this same sitemap parser on a schedule and tell them what appeared, disappeared, or changed status. That is being built. If it is something you would use, [say so](https://github.com/Chasen1992/sitemap-extractor/issues/new?title=Monitor+request\&labels=monitor-request\&body=What+would+you+want+the+monitor+to+tell+you%2C+and+how+often%3F) — the requests decide what gets built first. Every run writes an offer for this to the `NEXT_STEP` key-value record, which is how that decision gets made on evidence rather than guesswork.

#### Known limits, stated rather than hidden

- A sitemap served in a legacy 8-bit charset that declares no charset at all is read as UTF-8 and its non-ASCII paths may show replacement characters. Declared charsets (XML prolog or `Content-Type`) are honoured, including ISO-8859-1.
- Hostnames in non-ASCII scripts are reported as the sitemap wrote them; the rows are not rewritten to punycode.
- A bot-challenge served as a plain `200` to a `HEAD` request is reported as `200`, because detecting it needs body bytes and `HEAD` has none. We do not spend a second request on every URL to guard an uncommon case.

#### Licence and attribution

This Actor is **free and open source software, licensed under GPL-3.0-or-later**. See [`LICENSE`](./LICENSE) for the terms and [`NOTICE`](./NOTICE) for third-party attribution.

It is a derivative work of [`ultimate-sitemap-parser`](https://github.com/GateNLP/ultimate-sitemap-parser) (GPL-3.0), which is used unmodified and provides sitemap discovery, tolerant parsing, index recursion and cycle protection. Because of that, any distribution of this Actor must remain GPL-3.0-or-later. The complete corresponding source is published with the Actor.

#### Not affiliated

This is an independent product. It is not affiliated with, endorsed by, or connected to any other sitemap extractor, sitemap parser, or scraping tool on Apify Store or elsewhere.

# Changelog

This Actor's version history is a separate document: https://apify.com/chasen/sitemap-extractor/changelog.md

# Actor input Schema

## `startUrls` (type: `array`):

One or more domains or URLs.

- A bare domain (`example.com`) makes the extractor discover the sitemap through robots.txt and the usual paths (`/sitemap.xml`, `/sitemap_index.xml`, `/wp-sitemap.xml`, …).
- A sitemap URL (`https://example.com/sitemap.xml`) is used directly as the seed. Sitemap index files are followed automatically.
- A normal page URL behaves like a bare domain: the extractor looks for the sitemap belonging to that site.

## `maxUrls` (type: `integer`):

How many URL rows to return at most. This caps the **output** only — it does not cap how much work the run may do. A single sitemap index can reference thousands of child sitemaps, all of which have to be read before the first URL appears. Use `Max total requests` to bound the work.

With `Check status codes` on, each URL is probed at the target's own polite rate, so runtime grows roughly 0.3 s per URL plus the cost of reading the sitemaps. 200 rows is a couple of minutes; 10,000 rows on one host can take well over half an hour. The run summary marks `truncated: true` when this cap is the reason you did not get every URL.

## `checkStatusCodes` (type: `boolean`):

Probe every discovered URL and report its HTTP status code and content type.

Uses `HEAD` first and falls back to `GET` only when the server refuses `HEAD` (`405` / `501`). Only the status is recorded — page bodies are never read or stored. Turn this off to get the URL list without the extra requests; the run is then much faster and much cheaper.

## `followSitemapIndex` (type: `boolean`):

Recurse into `<sitemapindex>` files and read their child sitemaps. Needed for WordPress (`wp-sitemap.xml` is an index of indexes) and for any site that splits its sitemap by section. Turning it off returns only the top-level sitemap's own URLs.

## `maxSitemapDepth` (type: `integer`):

How deep to recurse through nested sitemap indexes. Depth 1 reads one level of children; depth 3 covers a WordPress install, which is an index of indexes. Cycles (A → B → A) are detected and refused regardless of this setting.

## `includeSubdomains` (type: `boolean`):

Keep URLs whose host is a subdomain of the start URL (e.g. `shop.example.com` when you started at `example.com`). Matching uses the Public Suffix List, so `example.co.uk` is treated as one site and `example.co.uk` vs `other.co.uk` are not.

`www.example.com` and `example.com` are one site and are always kept, whatever this is set to. Nearly every sitemap lists the apex, so a run that treated that pair as foreign would come back with nothing to check.

URLs on a genuinely different domain are always marked `cross_domain` and are never requested — a sitemap often lists CDN and partner hosts, and fetching them is not what you asked for.

## `proxyConfiguration` (type: `object`):

Optional proxy, for a stated geographic or access reason.

**This tool never rotates proxies.** If a target keeps answering `403` or serves a bot-challenge page, the run records it and moves on. Rotating proxies to get past a block is not something this product does — that is the line between checking status codes and evading a site's decision.

## `maxTotalChargeUsd` (type: `number`):

Stop the run before it charges you more than this, in US dollars.

Rows are charged one pay-per-event item each. When the ceiling is reached, the run stops pushing rows and says so in the run summary (`rowsDroppedForChargeLimit`) — the dataset is cut, not lost. Leave empty to be governed only by the platform's own limit. This is a safety net, not a price quote: it bounds the charge, not the compute.

## `maxRequestsTotal` (type: `integer`):

The request budget for the whole run — sitemap fetches, redirect hops, retries and status probes all count against it. This is what stops a runaway run: one sitemap index can legally reference 50,000 child sitemaps, and the status check then doubles the request count.

When the budget runs out the run ends cleanly with `truncated: true` in the summary and the remaining URLs marked `skipped_budget`. It never fails silently.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.apify.com"
    }
  ],
  "maxUrls": 200,
  "checkStatusCodes": true,
  "followSitemapIndex": true,
  "maxSitemapDepth": 3,
  "includeSubdomains": false,
  "maxRequestsTotal": 20000
}
```

# Actor output Schema

## `urls` (type: `string`):

Every URL found in the site's published sitemaps, one row each, with optional HTTP status codes. Fields are documented in the output schema; errorType is an enum, so problems are filterable rather than free text.

## `summary` (type: `string`):

What the run found and what it could not. Read truncated before concluding a site is small — it is true whenever maxUrls or a budget is why you did not get every URL, and truncateReason says which.

## `sitemaps` (type: `string`):

One record per sitemap file that was read, with its own status, kind and URL count. A site that publishes 24 sitemap files produces 24 records here.

## `nextStep` (type: `string`):

The run's closing note, including the offer to have these URLs watched for changes.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        {
            "url": "https://www.apify.com"
        }
    ],
    "maxUrls": 200
};

// Run the Actor and wait for it to finish
const run = await client.actor("chasen/sitemap-extractor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "startUrls": [{ "url": "https://www.apify.com" }],
    "maxUrls": 200,
}

# Run the Actor and wait for it to finish
run = client.actor("chasen/sitemap-extractor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrls": [
    {
      "url": "https://www.apify.com"
    }
  ],
  "maxUrls": 200
}' |
apify call chasen/sitemap-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,chasen/sitemap-extractor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/RyOI6FnJ2WrLgc6Zi/builds/C32tP97LMf72eW9zS/openapi.json
