# Sitemap URL Extractor & New Page Monitor (`moha-tah/sitemap-extractor`) Actor

Extract every URL from a website's XML sitemaps (auto-discovered from robots.txt, sitemap indexes, .gz, hreflang, news and image sitemaps) or monitor sitemaps for new, modified and removed pages. Fast HTTP-only, pay per URL.

- **URL**: https://apify.com/moha-tah/sitemap-extractor.md
- **Developed by:** [Mohamed T.](https://apify.com/moha-tah) (community)
- **Categories:** SEO tools, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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

**Get every URL of a website in seconds, or get alerted when it publishes, updates or removes pages.** Give it a domain: it finds the sitemaps (robots.txt, sitemap indexes, `.xml.gz`, text and RSS sitemaps), and returns each URL with `lastmod`, `changefreq`, `priority`, hreflang alternates, image and news data.

In **monitor mode** it remembers the previous run and outputs **only what changed**: new product pages, fresh blog posts, updated landing pages, deleted URLs. Schedule it daily and plug it into Slack, email or a Google Sheet.

### What does Sitemap URL Extractor do?

- **Auto-discovers sitemaps** from `robots.txt`, then common locations (`/sitemap.xml`, `/sitemap_index.xml`, `/wp-sitemap.xml`, …), or uses the sitemap URL you give it.
- **Follows sitemap indexes recursively** and decompresses `.gz` files. It also handles huge sitemaps and tolerates slightly broken XML.
- **Extracts everything the protocol offers**: `loc`, `lastmod` (normalized to ISO-8601), `changefreq`, `priority`, `xhtml:link` hreflang alternates, image URLs, Google News title and publication date.
- **Filters** by regex (include/exclude) and by modification date ("modified in the last 7 days").
- **Monitors changes** between runs: `added`, `modified` (lastmod changed) and `removed` URLs.

It's HTTP-only and polite (robots.txt respected, per-host delays, retries with backoff), so it's fast and cheap.

### Why use it?

- **SEO audits and migrations**: list all indexable URLs, compare staging vs production, find pages missing hreflang.
- **Competitive intelligence**: know the day a competitor launches a product, a landing page or a pricing page.
- **Content monitoring**: track new articles from news sites, blogs or documentation.
- **Feed your crawlers and AI/RAG pipelines**: get a clean URL list before scraping, instead of crawling blindly.
- **E-commerce**: detect new and discontinued product pages across competitor catalogs.

### How to use it

1. Add one or more websites or sitemap URLs to **Websites or sitemap URLs**.
2. Keep **Mode = Extract** to list URLs, or pick **Monitor changes** and give the watchlist a **Monitor name**.
3. Optionally filter with **Only URLs matching** (e.g. `/blog/`) or **Modified after** (`7 days`).
4. Click **Start**, then download the results as JSON, CSV or Excel, or use the API.
5. For monitoring, create a **Schedule** (e.g. every morning) and add an integration (Slack, email, webhook, Google Sheets).

### Input example

```json
{
  "startUrls": ["https://apify.com", "https://www.bbc.co.uk/food/sitemap.xml"],
  "mode": "extract",
  "includeUrlPatterns": ["/recipes/"],
  "lastmodAfter": "30 days",
  "maxUrlsPerSite": 10000
}
```

### Output example

Extract mode, one row per URL:

```json
{
  "url": "https://www.bbc.co.uk/food/recipes/deep-filled_lemon_50034",
  "site": "https://www.bbc.co.uk",
  "sitemapUrl": "https://www.bbc.co.uk/food/sitemap.xml",
  "lastmod": "2014-01-29",
  "changefreq": null,
  "priority": null,
  "alternates": []
}
```

Monitor mode, one row per change:

```json
{
  "url": "https://www.example.com/products/new-sneaker",
  "site": "https://www.example.com",
  "lastmod": "2026-09-27T08:12:00Z",
  "changeType": "added",
  "detectedAt": "2026-09-27T09:00:03+00:00"
}
```

A per-site summary (sitemaps found, URL count, discovery method, errors) is saved in the key-value store record `SUMMARY`.

#### Data fields

| Field | Description |
|---|---|
| `url` | Page URL from the sitemap |
| `site` | Origin of the website |
| `sitemapUrl` | Sitemap file where the URL was found |
| `lastmod`, `changefreq`, `priority` | Values declared in the sitemap (lastmod normalized to ISO-8601) |
| `alternates` | hreflang alternates `[{hreflang, url}]` |
| `images` | Image URLs (optional) |
| `newsTitle`, `newsPublicationDate` | Google News sitemap data |
| `changeType`, `previousLastmod`, `detectedAt` | Monitor mode only: `added`, `modified`, `removed` (or `baseline`) |

### How much does it cost?

Pay per event. **Extract mode**: a small price per URL returned. **Monitor mode**: a small fee per site checked plus a price per detected change. Unchanged URLs cost nothing. See the **Pricing** tab. Use **Max URLs per site** to cap test runs.

### Tips

- Monitoring many sites? Use one **Monitor name** per watchlist; each site keeps its own state.
- The first monitor run only stores a baseline (enable **Output all URLs on the first run** if you want them).
- When a limit truncates the crawl, removed pages aren't reported, to avoid false alarms.
- Big news sites publish separate news sitemaps. Pass them directly for the freshest articles.

### FAQ

**The site has no sitemap. What happens?**
The site is reported in `SUMMARY` with the reason, and you aren't charged for it. Sitemap-less sites need a crawler instead.

**Why are some `lastmod` values missing or old?**
The Actor returns what the website declares. Many sites omit `lastmod` or never update it.

**Is it legal?**
Sitemaps are published by websites precisely so machines can read them. The Actor respects robots.txt and collects no personal data.

**Found a sitemap it can't read?**
Open an issue on the **Issues** tab with the URL. Fixes usually ship within days.

# Actor input Schema

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

A website (https://example.com: sitemaps are discovered from robots.txt and common paths) or a direct sitemap / sitemap index URL (.xml, .xml.gz, .txt, RSS).

## `mode` (type: `string`):

Extract = list every URL. Monitor = only report URLs added, modified or removed since the previous run with the same monitor name (schedule it daily or weekly). The first monitor run stores a baseline.

## `monitorName` (type: `string`):

Monitor mode only. Runs with the same name share state. Use different names for independent watchlists.

## `includeUrlPatterns` (type: `array`):

Keep URLs matching at least one regular expression, e.g. /blog/ or /products/.

## `excludeUrlPatterns` (type: `array`):

Drop URLs matching any of these regular expressions, e.g. /tag/ or ?page=.

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

Keep only URLs whose <lastmod> is after this date. Accepts 2026-01-31 or a relative value like '7 days' or '24 hours'. URLs without lastmod are dropped when set.

## `maxUrlsPerSite` (type: `integer`):

Stop collecting a site after this many URLs (0 = unlimited). Keeps test runs cheap.

## `includeAlternates` (type: `boolean`):

Adds the language/region alternate URLs declared in the sitemap.

## `includeImages` (type: `boolean`):

Adds up to 20 image URLs per page from image sitemaps.

## `reportModified` (type: `boolean`):

Monitor mode: report URLs whose lastmod changed.

## `reportRemoved` (type: `boolean`):

Monitor mode: report URLs that disappeared from the sitemaps (skipped when a limit truncated the crawl).

## `emitBaseline` (type: `boolean`):

Monitor mode: also output every URL (changeType 'baseline') on the first run.

## `maxSitemapsPerSite` (type: `integer`):

Safety limit for very large sitemap indexes.

## `respectRobotsTxt` (type: `boolean`):

Skip sitemap files disallowed by robots.txt.

## `maxConcurrency` (type: `integer`):

Sites processed at the same time. Each site is fetched politely, one sitemap after another.

## Actor input object example

```json
{
  "startUrls": [
    "https://apify.com"
  ],
  "mode": "extract",
  "monitorName": "default",
  "includeUrlPatterns": [],
  "excludeUrlPatterns": [],
  "maxUrlsPerSite": 10000,
  "includeAlternates": true,
  "includeImages": false,
  "reportModified": true,
  "reportRemoved": true,
  "emitBaseline": false,
  "maxSitemapsPerSite": 500,
  "respectRobotsTxt": true,
  "maxConcurrency": 5
}
```

# Actor output Schema

## `results` (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": [
        "https://apify.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("moha-tah/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": ["https://apify.com"] }

# Run the Actor and wait for it to finish
run = client.actor("moha-tah/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": [
    "https://apify.com"
  ]
}' |
apify call moha-tah/sitemap-extractor --silent --output-dataset

```

## MCP server setup

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