# Sitemap Extractor – All URLs, lastmod, Nested & .gz (`appetizing_horsefly/sitemap-url-extractor`) Actor

Extract every page URL from a website's XML sitemaps with lastmod, changefreq, priority and image counts. Finds sitemaps through robots.txt automatically and handles nested indexes and .xml.gz. Optional mode returns only URLs new since the last run.

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

## Pricing

$0.30 / 1,000 urls

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 URL Extractor: get every URL from any website's sitemap

**Extract every page URL from a website's XML sitemaps in seconds**, with `lastmod`, `changefreq`, `priority`, image counts and hreflang counts. Sitemaps are found automatically through `robots.txt`, `/sitemap.xml` and `/sitemap_index.xml`. Nested sitemap indexes, `.xml.gz` and plain-text sitemaps all work.

Use it for **SEO audits, content inventories, competitor new-page monitoring, migration checks, and feeding crawlers or RAG pipelines**.

### Features

- **Sitemap discovery**: robots.txt `Sitemap:` lines, plus the common default paths.
- **Recursive**: follows sitemap indexes, with a `maxSitemaps` safety cap.
- **Filters**: include and exclude regexes, and `lastmodAfter` for recently changed pages.
- **New-page monitor**: `onlyNewSinceLastRun` outputs only URLs you haven't seen before. Schedule it daily.
- **No paying for junk**: duplicate URLs across sitemaps are removed before output. If no sitemap can be read, the run fails loudly and nothing is charged.
- **Hard caps**: `maxUrls`, per-request timeout, 3 retries.

### Use cases

- **SEO audits:** get the full URL inventory of a site (or a competitor's) with lastmod dates.
- **Competitor content monitoring:** turn on `onlyNewSinceLastRun` and schedule daily to see every new page they publish.
- **Crawl seeding:** feed exact URL lists into a content crawler or screenshot tool instead of blind link-following.
- **Migrations:** build redirect maps by comparing old and new sitemaps.

### Try it free in 1 click

The input form is **prefilled with a small, working example**. Press **Start** without changing anything: the run extracts 50 URLs from the crawlee.dev sitemap. Our test run of exactly this input finished in about 2 seconds with 50 results. At list price that is about $0.01, which fits inside the free monthly credit of Apify's free plan. Then swap in your own values.

Prefilled input:

```json
{
  "sites": [
    "https://crawlee.dev"
  ],
  "maxUrls": 50
}
```

### Sample output

Real rows from the prefilled run on 2026-10-14 (5 of 50 results shown; long fields trimmed). Download the full dataset as JSON, CSV or Excel.

| url | path | changefreq | priority | lastmod |
|---|---|---|---|---|
| https://crawlee.dev/blog | /blog | weekly | 0.50 | – |
| https://crawlee.dev/blog/archive | /blog/archive | weekly | 0.50 | – |
| https://crawlee.dev/blog/authors | /blog/authors | weekly | 0.50 | – |
| https://crawlee.dev/blog/building-gradcracke… | /blog/building-gradcracker-scraper-with-crawlee | weekly | 0.50 | – |
| https://crawlee.dev/blog/common-problems-in-… | /blog/common-problems-in-web-scraping | weekly | 0.50 | – |

### Input (copy-paste)

```json
{
  "sites": ["https://crawlee.dev", "https://www.allbirds.com/sitemap.xml"],
  "includePatterns": ["/docs/", "/products/"],
  "lastmodAfter": "2026-01-01",
  "maxUrls": 10000
}
```

### API (copy-paste)

```bash
curl -X POST "https://api.apify.com/v2/acts/appetizing_horsefly~sitemap-url-extractor/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H 'Content-Type: application/json' -d '{"sites":["https://crawlee.dev"],"maxUrls":500}'
```

### Output

```json
{"url":"https://crawlee.dev/js/docs/quick-start","lastmod":"2026-09-30","changefreq":"weekly","priority":0.5,"imageCount":0,"sitemapUrl":"https://crawlee.dev/sitemap.xml","site":"https://crawlee.dev"}
```

A per-site report (sitemap files read, errors, caps hit) is saved as `SUMMARY`.

### Full JSON of one result (real run)

```json
{
  "url": "https://crawlee.dev/blog",
  "lastmod": null,
  "changefreq": "weekly",
  "priority": 0.5,
  "imageCount": 0,
  "alternateLanguages": 0,
  "sitemapUrl": "https://crawlee.dev/sitemap.xml",
  "site": "https://crawlee.dev",
  "path": "/blog",
  "extractedAt": "2026-10-12T17:47:29.409Z"
}
```

### Pricing

Pay per event: **$0.0003 per URL** ($0.30 per 1,000 URLs). Duplicates, filtered and already-seen URLs are free.

### Use it as an MCP tool (Claude, Cursor, ChatGPT, any AI agent)

This Actor works as a tool in the [Apify MCP server](https://mcp.apify.com), so an AI agent can call it directly and you pay per result, the same as a normal run. Add this server URL to any MCP client:

```
https://mcp.apify.com/?tools=appetizing_horsefly/sitemap-url-extractor
```

Sign in with your Apify account (or pass your Apify API token as a Bearer header). The agent reads the input fields above from the Actor's input schema. Example request to the agent: "List every URL in crawlee.dev's sitemap that was modified in the last 30 days."

### Support

Questions, a bug, or a data source you need? Use this Actor's **Issues** tab or email **gm-labs@mail.grokbot.com**. Built and maintained by GM Labs.

# Actor input Schema

## `sites` (type: `array`):

Domains (sitemaps found automatically via robots.txt, /sitemap.xml, /sitemap_index.xml) or direct sitemap URLs, including .xml.gz and plain-text sitemaps.

## `includePatterns` (type: `array`):

Keep only URLs matching ANY of these regexes, e.g. /blog/ or /products/. Empty = all.

## `excludePatterns` (type: `array`):

Drop URLs matching any of these regexes.

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

Keep only URLs whose lastmod is on or after this date (YYYY-MM-DD). URLs without lastmod are kept unless 'Require lastmod' is on.

## `requireLastmod` (type: `boolean`):

Drop URLs that have no lastmod when a date filter is set.

## `onlyNewSinceLastRun` (type: `boolean`):

Remember URLs from previous runs (named key-value store) and output only new ones - a new-page / new-product monitor.

## `stateStoreName` (type: `string`):

Named key-value store for 'only new' memory.

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

Stop after this many output URLs. You are never billed for more. 0 = no cap.

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

Safety cap on nested sitemap files fetched per site.

## `requestTimeoutSecs` (type: `integer`):

Per-request timeout; retried 3 times.

## Actor input object example

```json
{
  "sites": [
    "https://crawlee.dev"
  ],
  "requireLastmod": false,
  "onlyNewSinceLastRun": false,
  "stateStoreName": "sitemap-urls-state",
  "maxUrls": 50,
  "maxSitemaps": 500,
  "requestTimeoutSecs": 30
}
```

# Actor output Schema

## `results` (type: `string`):

All results in the default dataset

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

Counts, caps hit, errors

# 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 = {
    "sites": [
        "https://crawlee.dev"
    ],
    "maxUrls": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("appetizing_horsefly/sitemap-url-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 = {
    "sites": ["https://crawlee.dev"],
    "maxUrls": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("appetizing_horsefly/sitemap-url-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 '{
  "sites": [
    "https://crawlee.dev"
  ],
  "maxUrls": 50
}' |
apify call appetizing_horsefly/sitemap-url-extractor --silent --output-dataset

```

## MCP server setup

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