# Sitemap URL Extractor — All Pages, Lastmod, Images, Hreflang (`docflow-tools/sitemap-url-extractor-reliable`) Actor

Get every URL of a website from its sitemaps: finds them in robots.txt and usual paths, follows sitemap indexes, opens .gz, reads lastmod, priority, images, hreflang and news. Filter by pattern or date. No duplicates. Failed sitemaps are free.

- **URL**: https://apify.com/docflow-tools/sitemap-url-extractor-reliable.md
- **Developed by:** [DocFlow Tools](https://apify.com/docflow-tools) (community)
- **Categories:** SEO tools, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.24 / 1,000 url founds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 — All Pages, Lastmod, Images, Hreflang

Get the list of URLs of a website from its XML sitemaps. Give it a domain (`example.com`) or a direct sitemap link.
It finds the sitemaps in `robots.txt` or at the usual paths, follows sitemap indexes, opens `.gz` files and plain-text
sitemaps, and returns one row per URL with `lastmod`, `changefreq`, `priority`, images, hreflang alternates and
Google News data when the sitemap has them. You can filter by regular expression and by "modified since" date.
Each URL is delivered once per run. A sitemap that fails is reported in the run summary, does not stop the run and
costs nothing.

### What you get

- **Sitemap discovery.** For a domain, the actor reads the `Sitemap:` lines in `robots.txt`. If there are none, it
  tries these paths in order and uses the first one that is a valid sitemap: `/sitemap.xml`, `/sitemap_index.xml`,
  `/sitemap-index.xml`, `/wp-sitemap.xml`, `/sitemap.xml.gz`.
- **Direct sitemap links.** Any input ending in `.xml`, `.xml.gz`, `.gz` or `.txt` (except `robots.txt`) is read
  as a sitemap directly.
- **Sitemap indexes** are followed at any depth (up to the `maxSitemaps` limit).
- **Formats:** XML sitemaps (with or without namespaces, with a BOM), gzip-compressed sitemaps (detected by content,
  not only by file name) and text sitemaps (one URL per line).
- **Per URL:** `lastmod`, `changefreq`, `priority`, image URLs (`image:image`), hreflang alternates
  (`xhtml:link`), and Google News title and publication date.
- **Filters:** keep URLs matching any include pattern, drop URLs matching any exclude pattern, keep only URLs whose
  `lastmod` is on or after a date.
- **No duplicates:** a URL that appears in several sitemaps is delivered (and charged) once.
- **Run summary** in the key-value store (`SUMMARY`): sitemaps read, URLs delivered, URLs filtered out, and the
  errors per sitemap or input.

### Use cases

- Build a full URL list of a site before an SEO audit, a migration or a content inventory.
- Find pages changed since a date (for example, to re-index or re-check only what changed).
- Get only one section of a site, such as `/blog/` or `/products/`.
- Check hreflang alternates and image entries declared in the sitemaps.
- Feed the URL list into another Actor (crawler, screenshot tool, Markdown converter) or a spreadsheet.

### How to use

1. Open the Actor in Apify Console and click **Try for free** / **Start**.
2. In **Websites or sitemap URLs**, add one or more domains or sitemap links.
3. Optionally add **Only URLs matching**, **Skip URLs matching** or **Modified since**.
4. Set **Max URLs** to the most URLs you want to pay for (see Pricing).
5. Run it. Results appear in the **Output** tab; download them as JSON, CSV, Excel or other formats.

#### Input example

```json
{
  "startUrls": ["example.com", "https://www.example.org/sitemap_index.xml"],
  "includePatterns": ["/blog/"],
  "excludePatterns": ["\\?page="],
  "modifiedSince": "2026-01-01",
  "maxUrls": 5000,
  "maxSitemaps": 1000
}
```

| Field | Type | Default | Meaning |
|---|---|---|---|
| `startUrls` | array of strings | required | Domains or direct sitemap links (`.xml`, `.xml.gz`, `.txt`). |
| `includePatterns` | array of regex | none | Keep a URL if it matches at least one pattern. |
| `excludePatterns` | array of regex | none | Drop a URL if it matches any pattern. |
| `modifiedSince` | date (`YYYY-MM-DD`) | none | Keep URLs with `lastmod` on or after this date. URLs without `lastmod` are skipped when this is set. |
| `maxUrls` | integer | 50,000 | Stop after this many URLs are delivered. |
| `maxSitemaps` | integer | 1,000 | Maximum number of sitemap files read per run. |

Patterns are Python regular expressions searched anywhere in the URL.

### Output example

One dataset item per URL. Fields that are empty in the sitemap are left out of the item.

```json
{
  "url": "https://example.com/blog/how-to-start",
  "lastmod": "2026-10-02T08:15:00+00:00",
  "changefreq": "weekly",
  "priority": 0.8,
  "images": ["https://example.com/img/how-to-start.jpg"],
  "alternates": [
    { "hreflang": "es", "href": "https://example.com/es/blog/como-empezar" }
  ],
  "sitemap": "https://example.com/post-sitemap.xml",
  "input": "example.com"
}
```

News sitemaps add `newsTitle` and `newsPublicationDate`. `sitemap` is the file the URL came from; `input` is the
start entry that led to it.

The `SUMMARY` record in the key-value store looks like this:

```json
{
  "inputs": 2,
  "sitemapsRead": 7,
  "urlsOutput": 5000,
  "urlsFilteredOut": 1834,
  "errors": [{ "source": "https://example.org/sitemap-old.xml", "error": "Client error '404 Not Found' ..." }],
  "stoppedEarly": true,
  "stoppedAtSpendingLimit": false
}
```

If no URL is delivered, the dataset gets one free item with `"status": "no_urls"` and the same summary fields, so
you can see why.

### Pricing

> **Prices by Apify discount tier:** the prices below are for the Bronze tier. **Free plan: 50 % off.** Silver: 10 % off. Gold and higher: 20 % off. Apify applies the right price automatically.

Pay per event, in USD:

| Event | Price | When |
|---|---|---|
| Actor start | $0.00005 | Charged by Apify when a run starts, per GB of run memory (default memory: 512 MB) |
| `url-found` | $0.0003 | For each URL delivered to the dataset. |

Not charged: duplicate URLs, URLs removed by your filters, failed sitemaps and the `no_urls` status item.

**Control spend with `maxUrls`.** The default is 50,000 URLs (up to $15). Large sites can have millions of URLs,
so set `maxUrls` to what you need. The run also stops cleanly if it reaches the maximum cost per run you set in
Apify.

Examples:

- 100 URLs: $0.00005 + 100 × $0.0003 = **$0.03005**
- 10,000 URLs: $0.00005 + 10,000 × $0.0003 = **$3.00005**
- A site with 80,000 URLs, `includePatterns: ["/blog/"]` keeps 2,500: $0.00005 + 2,500 × $0.0003 = **$0.75005**
  (the 77,500 filtered URLs are free).

### Use it from code, AI agents and integrations

**Apify API (one call, returns the dataset items):**

```bash
curl -X POST "https://api.apify.com/v2/acts/docflow-tools~sitemap-url-extractor-reliable/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"startUrls": ["example.com"], "maxUrls": 1000}'
```

Synchronous endpoints wait a limited time; for very large sites start the run asynchronously and read the dataset
when it finishes.

**Python (`apify-client`):**

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("docflow-tools/sitemap-url-extractor-reliable").call(
    run_input={"startUrls": ["example.com"], "includePatterns": ["/blog/"], "maxUrls": 1000}
)
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["url"], item.get("lastmod"))

summary = client.key_value_store(run["defaultKeyValueStoreId"]).get_record("SUMMARY")["value"]
```

**AI agents:** the Actor can be called by AI agents through the Apify MCP server at https://mcp.apify.com.

**No-code:** connect it to Make, Zapier, n8n and other tools through Apify integrations, or schedule it in Apify.

### Limits and notes

- Only sitemaps are read. The actor does not open or crawl the pages themselves, so it returns what the sitemaps
  declare. Pages missing from the sitemaps are not found.
- `robots.txt` is read only to find `Sitemap:` lines.
- Only `http` and `https` URLs are fetched. Domains that resolve to private, loopback, link-local or other internal
  addresses are blocked.
- Sitemap URLs listed in `robots.txt` or in a sitemap index are followed as given, even if they are on another host.
- Each downloaded sitemap file can be up to 100 MB; larger downloads are reported as errors.
- Up to 8 sitemap files are downloaded in parallel; each request has a 60-second timeout.
- `maxSitemaps` counts every sitemap file attempted, including those that fail.
- The `errors` list in `SUMMARY` keeps the first 200 errors.
- When `modifiedSince` is set, URLs without `lastmod` are skipped.

### FAQ

**Do I pay for duplicates or filtered URLs?**
No. Only URLs delivered to the dataset are charged. A URL is checked for duplicates before the filters run.

**What if the site has no `Sitemap:` line in robots.txt?**
The actor tries the usual sitemap paths listed above. If none is a valid sitemap, the input is listed in `errors`
with "no sitemap found in robots.txt or usual locations".

**Can I give a sitemap index directly?**
Yes. Any link ending in `.xml`, `.xml.gz`, `.gz` or `.txt` is read directly, and indexes are followed.

**How do I get only recently changed pages?**
Set `modifiedSince` (for example `2026-01-01`). Only URLs with a `lastmod` on or after that date are kept.

**Does one broken sitemap stop the run?**
No. It is listed in `SUMMARY.errors` and the other sitemaps continue.

### Related tools

- [Document to Markdown for RAG](https://apify.com/docflow-tools/document-to-markdown-rag) — PDF, Word, Excel, PowerPoint and HTML files to Markdown with tables and RAG chunks; OCR for scanned pages.
- [RSS, Atom & JSON Feed Reader — only new items](https://apify.com/docflow-tools/feed-reader-only-new) — read feeds in one format and get only items you have not received before.
- [Bulk PageSpeed & Core Web Vitals](https://apify.com/docflow-tools/pagespeed-bulk-regression-monitor) — PageSpeed Insights for many URLs (your own free key), with alerts when pages get worse.
- [Image to Text OCR](https://apify.com/docflow-tools/image-ocr-own-engine) — text from images with each line, its position and confidence.
- [Audio & Video Transcriber](https://apify.com/docflow-tools/audio-transcriber-whisper-local) — Whisper running locally; text, timestamps, SRT and VTT.
- [Merge, Deduplicate & Convert Datasets](https://apify.com/docflow-tools/merge-dedupe-transform-data) — merge datasets and CSV/JSON/Excel files, remove duplicates, export to CSV or Excel.
- [Website Screenshot & Visual Change Monitor](https://apify.com/docflow-tools/website-screenshot-monitor) — bulk screenshots (PNG, JPEG, PDF) with optional change detection.
- [Bulk Image Converter & Compressor](https://apify.com/docflow-tools/bulk-image-converter-compressor) — convert, compress and resize images to WebP, AVIF, JPEG or PNG.
- [SEO Audit Crawler](https://apify.com/docflow-tools/seo-audit-crawler-cheap) — 0-100 on-page SEO score per page, each issue with severity and fix.
- [Website to Markdown + llms.txt](https://apify.com/docflow-tools/website-to-markdown-llms-txt) — websites to clean Markdown for LLMs and RAG, plus llms.txt files.

# Actor input Schema

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

Domains (example.com) or direct sitemap links (…/sitemap.xml, .xml.gz, .txt). For domains, sitemaps are found in robots.txt or usual paths.

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

Regular expressions; keep URLs that match at least one (e.g. /blog/).

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

Regular expressions; drop URLs that match any (e.g. ?page=).

## `modifiedSince` (type: `string`):

Only URLs whose lastmod is on or after this date. URLs without lastmod are skipped when set.

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

Stop after this many URLs (default 50,000 = up to $15). Raise it for very big sites; you are charged only for URLs delivered.

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

Safety limit on how many sitemap files are read per run.

## Actor input object example

```json
{
  "startUrls": [
    "https://apify.com/sitemap/pages.xml"
  ],
  "maxUrls": 100,
  "maxSitemaps": 1000
}
```

# 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/sitemap/pages.xml"
    ],
    "maxUrls": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("docflow-tools/sitemap-url-extractor-reliable").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/sitemap/pages.xml"],
    "maxUrls": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("docflow-tools/sitemap-url-extractor-reliable").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/sitemap/pages.xml"
  ],
  "maxUrls": 100
}' |
apify call docflow-tools/sitemap-url-extractor-reliable --silent --output-dataset

```

## MCP server setup

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

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/2DKbH53f9rqAGCCEB/builds/ssi89FJtPcnijUqTs/openapi.json
