# Sitemap URL Extractor: SEO URL Inventory (`ailu_studio/sitemap-url-extractor`) Actor

Extract URLs from XML sitemaps and sitemap indexes. Filter URL patterns and last-modified dates for SEO audits and crawl planning.

- **URL**: https://apify.com/ailu_studio/sitemap-url-extractor.md
- **Developed by:** [Ailu Studio](https://apify.com/ailu_studio) (community)
- **Categories:** SEO tools, Developer tools, Marketing
- **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 sitemap url rows

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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: SEO URL Inventory

Extract URLs from XML sitemaps and sitemap indexes. Filter URL patterns and last-modified dates for SEO audits and crawl planning.

### Try a small sample

Paste this into the Input JSON editor, run the Actor, then inspect its dataset. Export JSON or CSV from the dataset, or use the API tab for authenticated integration examples.

```json
{
  "websites": [
    "https://docs.python.org"
  ],
  "maxUrlsPerSite": 20,
  "maxSitemaps": 3,
  "maxItems": 20
}
```

### Workflow example

Create an inventory before a content audit. Sitemap lastmod values are publisher-provided; URLs absent from a sitemap can still exist on the site.

```json
{
  "websites": [
    "https://docs.python.org"
  ],
  "urlContains": [
    "/library/"
  ],
  "maxUrlsPerSite": 100,
  "maxSitemaps": 5,
  "maxItems": 50
}
```

Examples show supported inputs, not guaranteed result counts. Public sources and filters can produce fewer rows or zero rows. Check the run log and any summary/error records before treating the output as complete.

For recurring use, save the input as an Apify Task and schedule sequential runs. Export results to your own spreadsheet, database, n8n or Make workflow. Scheduling does not add stateful tracking to Actors that only return snapshots. Keep API credentials in environment variables.

### Related workflow

[Broken Link Checker: 404s, Errors & Redirects](https://apify.com/ailu_studio/broken-link-checker) can complement this Actor. It runs separately and has its own price and input requirements.

### Detailed reference

### Sitemap URL Extractor: All URLs from sitemap.xml, Sitemap Indexes, .xml.gz and Feeds

Get every URL a website lists in its XML sitemaps, as clean JSON or CSV. Give the Actor a website address and it finds the sitemaps itself (from the `Sitemap:` lines in robots.txt, otherwise `/sitemap.xml`, `/sitemap_index.xml` and `/sitemap-index.xml`), follows sitemap indexes recursively, and reads gzipped `.xml.gz` sitemaps, plain-text URL lists and RSS/Atom feeds used as sitemaps. Each URL row carries `lastmod`, `changefreq`, `priority`, image count and image URLs, Google News title and publication date, and hreflang alternates. Filters for URL substrings, modification date and host keep the output focused. Compared with other sitemap extractors in the Store, this one returns news, image and hreflang data per URL, skips child sitemaps that were not modified since your date filter, honours robots.txt, and adds a free per-site summary row (sitemaps found, URLs found, errors) so you can see why a site returned nothing.

### Use cases

- SEO audits: list all indexable URLs, compare with crawled pages, check `lastmod` freshness and hreflang coverage.
- Content monitoring: pull only URLs modified since a date (`lastmodSince`) to find new or updated pages, products or articles.
- Crawl seeding: feed the URL list into a scraper or link checker instead of crawling the whole site.
- News and publisher tracking: read Google News sitemaps (title, publication date) of media sites.
- Site migrations: export old and new sitemap URLs to build redirect maps.

### Input

| Field | Default | Meaning |
|---|---|---|
| `websites` | `["https://docs.python.org", "https://apify.com"]` | Website addresses or direct sitemap/feed URLs. A URL with a path is read as a sitemap first; if it is an ordinary page, the site's sitemaps are discovered instead. |
| `maxUrlsPerSite` | `5000` | Stop reading a site's sitemaps once this many URL rows were returned for it. |
| `maxSitemaps` | `50` | Maximum sitemap files (indexes and URL sets) fetched per site. |
| `urlContains` | `[]` | Keep only URLs containing at least one of these strings. |
| `urlExcludes` | `[]` | Drop URLs containing any of these strings. |
| `lastmodSince` | empty | Keep only URLs with `lastmod` on or after this date (URLs without `lastmod` are dropped). |
| `sameHostOnly` | `true` | Keep only URLs on the site's own host (`www.` ignored). |
| `maxItems` | `2000` | Maximum charged URL rows across all sites. |

Example input:

```json
{ "websites": ["https://www.example.com", "https://blog.example.com/sitemap-posts.xml.gz"], "urlContains": ["/blog/"], "lastmodSince": "2026-10-01", "maxItems": 10000 }
```

### Output

| Field | Type | Meaning |
|---|---|---|
| `id` | string | SHA-1 of the URL, first 16 hex characters (site rows: `site:<input>`). |
| `rowType` | string | `url` (charged) or `site` (free summary). |
| `site` | string | Origin of the website. |
| `url` | string | Page URL from `<loc>`. |
| `lastmod` | ISO 8601 | null | `<lastmod>` (item date for feeds). |
| `changefreq`, `priority` | string, number | null | Sitemap hints when present. |
| `sitemapUrl` | string | Sitemap file the URL came from. |
| `imageCount`, `imageUrls` | integer, string\[] | `<image:image>` entries (first 10 URLs). |
| `newsTitle`, `newsPublishedAt` | string, ISO 8601 | null | Google News sitemap data. |
| `alternates` | object\[] | `[{hreflang, href}]` from `<xhtml:link rel="alternate">`. |
| `fetchedAt` | ISO 8601 | Run time. |

Site summary rows add `robotsTxt`, `sitemapsFound`, `sitemapsFetched`, `sitemapUrls`, `urlsFound`, `urlsMatched`, `urlsReturned`, `notes` and `errors`.

Sample URL row (alternates shortened):

```json
{
  "id": "338be181a2a92faf", "rowType": "url", "site": "https://docs.python.org", "url": "https://docs.python.org/3.11/",
  "lastmod": null, "changefreq": "yearly", "priority": null, "sitemapUrl": "https://docs.python.org/sitemap.xml",
  "imageCount": 0, "imageUrls": [], "newsTitle": null, "newsPublishedAt": null,
  "alternates": [{ "hreflang": "de", "href": "https://docs.python.org/de/3.11/" }, { "hreflang": "ja", "href": "https://docs.python.org/ja/3.11/" }],
  "fetchedAt": "2026-11-04T11:33:00.929Z"
}
```

Sample site row:

```json
{ "id": "site:https://apify.com", "rowType": "site", "site": "https://apify.com", "url": "https://apify.com", "robotsTxt": "ok", "sitemapsFound": 21, "sitemapsFetched": 3, "sitemapUrls": ["https://apify.com/sitemap.xml", "https://apify.com/sitemap/pages.xml", "https://apify.com/sitemap/actors1.xml"], "urlsFound": 51621, "urlsMatched": 51621, "urlsReturned": 1993, "notes": null, "errors": [], "fetchedAt": "2026-11-04T11:37:30.729Z" }
```

### How it works and limits

- Discovery order: direct URL given by you, else robots.txt `Sitemap:` lines, else the three common paths (the first that works is used). Sitemap indexes are followed breadth-first up to `maxSitemaps` files per site.
- robots.txt is read once per host and obeyed for every sitemap path that robots.txt does not itself declare (the `User-agent: *` group, or a group naming `apify-actor-sitemap-url-extractor`). If robots.txt is unreachable (5xx), nothing is fetched from that site.
- Requests are sequential with at least 500 ms between requests to the same host; 429 and 5xx answers are retried with backoff. A sitemap file may be up to 60 MB; gzip is detected by content, not by file name.
- URLs are de-duplicated across all sitemaps and sites in a run. Duplicate entries inside one site count in `urlsFound` but are returned once.
- The Actor reads what the site publishes in its sitemaps. Pages missing from the sitemaps are not discovered (no crawling), and `lastmod` is only as accurate as the site's own data.
- Not covered: JavaScript-generated sitemaps, sitemaps behind logins or bot walls, video sitemap details, and checking whether the listed URLs are live (use a link checker for that).

### Pricing

Pay per result: **$0.50 per 1,000 rows** (`result` event). Platform usage is billed separately by Apify. Removed/free rows are not charged.

Only URL rows are charged; the per-site summary rows are free.

### Legal

Not affiliated with any of the websites you extract. Uses the public sitemap files (sitemaps.org protocol) and robots.txt files that websites publish for crawlers only. Data licence/terms: https://www.sitemaps.org/protocol.html and the terms of each website you process. Respect each site's terms of use when you reuse the URLs.

### FAQ

**Why did a site return 0 URLs?** Look at its `site` row: `errors` tells you whether no sitemap was found, a sitemap returned an HTTP error, robots.txt disallowed it, or all URLs were removed by your filters (`urlsFound` > 0 but `urlsMatched` 0).

**Can I pass a sitemap URL directly?** Yes. Any URL with a path, including `.xml.gz` files, news sitemaps and RSS/Atom feeds, is read directly. If it turns out to be an ordinary page, the Actor discovers the site's sitemaps instead and says so in `notes`.

**How do I get only new pages?** Set `lastmodSince` to the date of your last run. Only URLs with a `lastmod` on or after that date are returned, and child sitemaps whose own `lastmod` is older are not downloaded.

**Why are some URLs on other domains missing?** `sameHostOnly` is on by default and drops URLs whose host differs from the site (for example a CDN or a separate shop domain). Turn it off to keep them.

**How large can a site be?** Each sitemap file can hold 50,000 URLs. Raise `maxUrlsPerSite`, `maxSitemaps` and `maxItems` for very large sites. Parsing is fast (a 50,000-URL sitemap file is read in a few seconds); run time grows mainly with the number of sitemap files, fetched at most two per second per host.

# Actor input Schema

## `websites` (type: `array`):

Website addresses (e.g. "https://apify.com") to discover sitemaps for, or direct sitemap/feed URLs (e.g. "https://example.com/sitemap-posts.xml.gz"). A URL with a path is first read as a sitemap; if it is a normal page, the site's sitemaps are discovered instead.

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

Stop reading a site's sitemaps once this many URLs (after filters) were returned for it.

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

Upper limit on sitemap files (indexes and URL sets) fetched per site, so huge sitemap trees stay bounded.

## `urlContains` (type: `array`):

Keep only URLs that contain at least one of these strings (case-insensitive), e.g. "/blog/". Empty keeps all.

## `urlExcludes` (type: `array`):

Drop URLs that contain any of these strings (case-insensitive), e.g. "/tag/" or "?replytocom".

## `lastmodSince` (type: `string`):

Keep only URLs whose <lastmod> is on or after this date (YYYY-MM-DD). URLs without lastmod are dropped when set, and child sitemaps last modified before the date are skipped.

## `sameHostOnly` (type: `boolean`):

Keep only URLs on the site's own host name (www. ignored). Turn off to keep URLs on other hosts listed in the sitemaps, e.g. a separate blog domain.

## `maxItems` (type: `integer`):

Upper limit on charged URL rows across all sites. The free summary row per site does not count.

## Actor input object example

```json
{
  "websites": [
    "https://docs.python.org",
    "https://apify.com"
  ],
  "maxUrlsPerSite": 5000,
  "maxSitemaps": 50,
  "urlContains": [],
  "urlExcludes": [],
  "sameHostOnly": true,
  "maxItems": 2000
}
```

# Actor output Schema

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

All rows in the default dataset.

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

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

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

```

## MCP server setup

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