# Sitemap Extractor & Change Monitor (`cheremikin/sitemap-extractor`) Actor

Extract every URL from website sitemaps: robots.txt discovery, nested indexes, .xml.gz, text, image/news/video, hreflang. Regex & lastmod filters. Change monitor mode outputs only added/removed/updated URLs. Respects robots.txt.

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

## Pricing

from $0.50 / 1,000 url extracteds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## 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 & Change Monitor

Get every URL a website publishes in its XML sitemaps — with `lastmod`, images, news metadata, video and hreflang alternates — and, in **change monitor mode**, only what was **added, removed or updated** since your last run.

Give it a site root (`https://example.com`) and it finds the sitemaps itself through `robots.txt` (`Sitemap:` lines), falling back to `/sitemap.xml` and `/sitemap_index.xml`. Or give it sitemap URLs directly.

### Features

| Feature | This actor | Typical sitemap extractors |
|---|---|---|
| Auto-discovery via robots.txt + standard locations | ✅ | partial |
| Nested sitemap indexes (depth limit) | ✅ | ✅ |
| Gzipped sitemaps (`.xml.gz`) | ✅ | often ❌ |
| Plain-text sitemaps (`.txt`) | ✅ | ❌ |
| Image, news, video extensions | ✅ | rarely |
| hreflang alternates | ✅ | rarely |
| Regex include / exclude filters | ✅ | sometimes |
| `lastmod` date range filter | ✅ | ❌ |
| **Change monitor** (added / removed / updated) | ✅ | ❌ |
| Per-sitemap counts and errors in a run summary | ✅ | ❌ |
| Respects robots.txt + Crawl-delay | ✅ | varies |
| Price | **$0.50 per 1,000 URLs** | — |

### Output

One dataset item per URL:

| Field | Example |
|---|---|
| `siteRoot` | `https://apify.com` |
| `sitemapUrl` | `https://apify.com/sitemap-store.xml` |
| `loc` | `https://apify.com/apify/web-scraper` |
| `lastmod` | `2026-11-16T08:12:00Z` |
| `changefreq` | `daily` |
| `priority` | `0.8` |
| `images` | `[{"loc": "https://…/cover.jpg"}]` |
| `news` | `{"title": "…", "publicationDate": "2026-11-17T09:10:21Z", "publicationName": "…", "publicationLanguage": "en"}` |
| `videos` | `[{"title": "…", "thumbnailLoc": "…", "contentLoc": "…"}]` |
| `alternates` | `[{"hreflang": "de", "href": "https://example.com/de/"}]` |
| `changeType` | `added` / `updated` / `removed` (monitor mode only) |
| `previousLastmod` | previous `lastmod` (monitor mode only) |

The `OUTPUT` record in the key-value store holds the run summary: per site, each sitemap fetched (type, depth, URL count, output count), errors, totals and — in monitor mode — counts of added / updated / removed.

### Input

- **startUrls** — site roots or sitemap URLs (`.xml`, `.xml.gz`, `.txt`).
- **maxUrls** (default 5000) — total URLs output; in monitor mode, total changes output.
- **maxSitemapDepth** (default 3), **maxSitemaps** per site (default 200).
- **urlIncludes / urlExcludes** — Python regular expressions on the URL.
- **lastmodAfter / lastmodBefore** — `YYYY-MM-DD` or ISO date-time.
- **changeMonitor** + **monitorStoreName** — snapshot per site in a named key-value store.
- **requestDelaySecs** (default 1, min 0.5) — polite delay per host; a larger robots.txt `Crawl-delay` always wins.

### Change monitor mode

Turn on `changeMonitor` and schedule the actor (e.g. daily). The first run outputs every URL as `added` and saves a snapshot. Every later run outputs only:

- `added` — new URLs in the sitemap,
- `updated` — `lastmod` changed,
- `removed` — URL disappeared from the sitemap.

If a sitemap fails to load or a limit is hit, removals are **not** reported for that run (so you don't get false "removed" alerts), and the snapshot keeps the URLs it couldn't check.

### Use cases

- **SEO audits** — full URL inventory, stale `lastmod`, missing hreflang, image coverage.
- **Content monitoring** — new competitor pages, product launches, deleted pages, news feeds.
- **Crawl seeding** — feed exact URL lists into a crawler instead of spidering a whole site.
- **AI agents & RAG** — give an agent a fresh list of a site's docs pages; re-index only what changed.

### Privacy & fair use

The actor reads only public sitemap files of the sites **you** choose. It fetches `robots.txt` first, never requests a path disallowed for it, honours `Crawl-delay`, sends one request at a time per host and identifies itself with a clear User-Agent. It does not bypass any bot protection; a site that blocks it simply shows an error in the summary. Sitemaps contain URLs and dates, not personal data. You are responsible for how you use the URLs.

Built and maintained by Alexandr Cheremikin (Koh Samui, Thailand) with an AI assistant.

# Actor input Schema

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

Site roots (e.g. https://example.com) to auto-discover sitemaps via robots.txt and /sitemap.xml, or direct sitemap URLs (.xml, .xml.gz, .txt).

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

Stop after this many URLs are output (across all sites). In monitor mode this caps the number of changes output.

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

How deep to follow nested sitemap indexes (0 = only the sitemaps you give or that are discovered).

## `maxSitemaps` (type: `integer`):

Safety limit on how many sitemap files are fetched per site.

## `urlIncludes` (type: `string`):

Only output URLs matching this regular expression (Python syntax), e.g. /blog/.

## `urlExcludes` (type: `string`):

Skip URLs matching this regular expression, e.g. .pdf$|/tag/.

## `lastmodAfter` (type: `string`):

Only URLs with lastmod on/after this date (YYYY-MM-DD or ISO). URLs without lastmod are dropped when a lastmod filter is set.

## `lastmodBefore` (type: `string`):

Only URLs with lastmod on/before this date (YYYY-MM-DD or ISO).

## `changeMonitor` (type: `boolean`):

Compare with the previous snapshot stored in a named key-value store and output only added / removed / updated URLs (changeType). The first run outputs all URLs as 'added'. Schedule the actor to get a change feed.

## `monitorStoreName` (type: `string`):

Name of the key-value store used to keep snapshots between runs (one record per site).

## `requestDelaySecs` (type: `number`):

Minimum polite delay between requests to the same site. A larger robots.txt Crawl-delay always wins.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://docs.python.org"
    },
    {
      "url": "https://apify.com"
    }
  ],
  "maxUrls": 5000,
  "maxSitemapDepth": 3,
  "maxSitemaps": 200,
  "changeMonitor": false,
  "monitorStoreName": "sitemap-monitor",
  "requestDelaySecs": 1
}
```

# Actor output Schema

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

No description

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

No description

# 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://docs.python.org"
        },
        {
            "url": "https://apify.com"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("cheremikin/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://docs.python.org" },
        { "url": "https://apify.com" },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("cheremikin/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://docs.python.org"
    },
    {
      "url": "https://apify.com"
    }
  ]
}' |
apify call cheremikin/sitemap-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,cheremikin/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/YR2E5k4JmvQ5a4iSK/builds/18VAe4syG6boB5dp9/openapi.json
