# Sitemap URL Extractor – All Website URLs with Lastmod (`iamshytv/sitemap-url-extractor`) Actor

Extract every page URL from any website's XML sitemaps. Auto-discovers sitemaps via robots.txt, follows sitemap indexes and .gz files, and returns lastmod, priority, changefreq, images and hreflang. Filter by regex or date. Fast, no browser.

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

## Pricing

$1.00 / 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 URL Extractor – Get All Website URLs from XML Sitemaps

Extract **every page URL of any website** from its XML sitemaps in seconds. Paste a domain and this Actor finds the sitemaps for you (robots.txt `Sitemap:` lines, `/sitemap.xml`, `/sitemap_index.xml`, `/wp-sitemap.xml`), follows **sitemap index files** and **gzipped `.xml.gz` sitemaps**, and returns each URL with **lastmod, changefreq, priority, image count, video flag, news title and hreflang alternates**. No browser, no proxies, no login.

### What can I use it for?

- **SEO audits & content inventories** – list all indexable pages of your site or a competitor's.
- **Change monitoring** – set *Only URLs modified after* and schedule daily to get just the new or updated pages.
- **Crawl seeding** – feed the URL list into Website Content Crawler, a link checker or an AI/RAG pipeline.
- **Migration checks** – compare URLs before/after a redesign or CMS migration.
- **Find all PDFs, blog posts or product pages** – filter with regex like `\.pdf$`, `/blog/` or `/products/`.

### Features

- Auto-discovery from robots.txt and common sitemap locations (WordPress, Yoast, Shopify, Next.js, Docusaurus…)
- Sitemap index recursion (up to 5 levels), `.gz` sitemaps, plain-text and RSS/Atom sitemaps
- Include / exclude **regex filters** and **lastmod date filter**
- **Per-website cap** so one huge site doesn't eat your budget
- Polite: retries with backoff, honours `Retry-After`, per-host rate limiting
- Clear error report per website in the `RUN_SUMMARY` record (no silent failures)

### Input example

```json
{
  "startUrls": ["apify.com", "https://crawlee.dev/sitemap.xml", "https://www.gov.uk"],
  "maxUrls": 5000,
  "maxUrlsPerSite": 2000,
  "includePatterns": ["/blog/"],
  "excludePatterns": ["/tag/"],
  "lastmodAfter": "2026-01-01"
}
```

### Output example

```json
{
  "url": "https://www.gov.uk/government/news/example",
  "lastmod": "2026-10-22T09:14:03+01:00",
  "changefreq": null,
  "priority": null,
  "imageCount": 0,
  "hasVideo": false,
  "newsTitle": null,
  "alternates": [],
  "sitemapUrl": "https://www.gov.uk/sitemaps/sitemap_1.xml",
  "domain": "www.gov.uk",
  "startUrl": "https://www.gov.uk"
}
```

Download as JSON, CSV, Excel, XML or HTML, or fetch via the Apify API.

### Pricing

Pay per event: **$1.00 per 1,000 URLs extracted** (you only pay for URLs returned). Set a max cost per run and the Actor stops cleanly at your limit.

### Use with AI agents (MCP)

This Actor is available as a tool in the [Apify MCP server](https://mcp.apify.com). Add it with
`https://mcp.apify.com?tools=<username>/sitemap-url-extractor` in Claude, Cursor, VS Code or any MCP client.

### FAQ

**The site has no sitemap?** The run summary lists it under `errors`. Use a crawler instead for that site.
**Is it legal?** Sitemaps are published by site owners specifically for automated consumption. The Actor only reads sitemap files and robots.txt, never page content.
**Why are some URLs missing with a date filter?** URLs without `<lastmod>` are excluded when *Only URLs modified after* is set.

Found a problem? Open an issue on the Actor's Issues tab – we respond fast.

# Actor input Schema

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

Domains (apify.com), any page URL, or direct sitemap URLs (https://example.com/sitemap.xml). Sitemaps are discovered from robots.txt and common locations.

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

Stop after this many URLs (across all start URLs). You pay per URL extracted.

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

Cap per start URL so one huge site doesn't use the whole budget. 0 = no per-site cap.

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

Only keep URLs matching at least one regex, e.g. /blog/ or .pdf$

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

Drop URLs matching any regex, e.g. /tag/ or /page/\d+

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

Keep only URLs whose <lastmod> is on/after this date (YYYY-MM-DD). URLs without lastmod are dropped when set. Great for change monitoring.

## `useRobotsTxt` (type: `boolean`):

Read Sitemap: lines in robots.txt before trying /sitemap.xml, /sitemap_index.xml, /wp-sitemap.xml.

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

Safety cap on how many sitemap files are fetched for each start URL.

## Actor input object example

```json
{
  "startUrls": [
    "https://www.python.org",
    "https://crawlee.dev/sitemap.xml"
  ],
  "maxUrls": 1000,
  "maxUrlsPerSite": 0,
  "includePatterns": [],
  "excludePatterns": [],
  "useRobotsTxt": true,
  "maxSitemaps": 500
}
```

# Actor output Schema

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

Every page URL found in the website's XML sitemaps (with lastmod, changefreq, priority, images, hreflang). Stored in the run's default dataset.

## `runSummary` (type: `string`):

JSON record RUN_SUMMARY in the default key-value store: counts and any per-input 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 = {
    "startUrls": [
        "https://www.python.org",
        "https://crawlee.dev/sitemap.xml"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("iamshytv/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 = { "startUrls": [
        "https://www.python.org",
        "https://crawlee.dev/sitemap.xml",
    ] }

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

```

## MCP server setup

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