# Sitemap URL Extractor - All URLs of Any Website (`sharkinho/sitemap-url-extractor`) Actor

Extract every URL from any website's sitemaps. Finds sitemaps via robots.txt and common paths, follows sitemap indexes, reads .xml.gz, image/video/news/hreflang extensions, filters by regex and lastmod, optional HTTP status check. Streams millions of URLs cheaply.

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

## Pricing

from $0.25 / 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 every URL of a website from its sitemaps

Give it a list of **domains or sitemap URLs** and get back **every page URL** the site publishes in its XML sitemaps, with `lastmod`, `changefreq`, `priority`, image, video, news and hreflang data. It finds the sitemaps for you, follows sitemap indexes of any depth, reads `.xml.gz` files, and streams huge sitemaps (millions of URLs) without running out of memory.

It only uses plain HTTP requests (no browser), so it is fast and cheap: **$0.25 per 1,000 URLs**.

### What it does

- **Auto-discovery.** For a domain it reads the `Sitemap:` lines in `robots.txt`. If there are none, it tries common locations: `/sitemap.xml`, `/sitemap_index.xml`, `/sitemap-index.xml`, `/wp-sitemap.xml` (WordPress), `/sitemap.xml.gz`, `/sitemap.txt`, `/sitemaps.xml`, and the usual news, image and video sitemap paths. Soft-404 HTML pages are ignored.
- **Sitemap indexes** are followed recursively (configurable depth), and every child sitemap is opened only once.
- **Gzip.** `.xml.gz` files are detected by their content, so they work whether or not the server sets `Content-Encoding`.
- **All formats.** Standard `<urlset>`, `<sitemapindex>`, plain-text sitemaps (one URL per line), RSS 2.0 and Atom feeds.
- **Sitemap extensions.** Google image (`image:image`), video (`video:video`), news (`news:news`) and hreflang alternates (`xhtml:link`) are extracted when present.
- **Streaming parser.** Sitemaps are parsed while they download, so a 50 MB sitemap with 50,000 URLs, or an index with thousands of them, uses about the same memory as a small one.
- **Lenient.** Unescaped `&`, odd namespace prefixes (`ns0:url`), BOMs and truncated files don't stop it. You get every entry it can read.
- **Filters.** Include / exclude URL regex patterns, `lastmod` modified after / before (absolute dates or relative like `30 days`), max URLs per site.
- **De-duplication.** A URL that appears in several sitemaps is returned once per site.
- **Optional status check.** A `HEAD` request per URL adds `statusCode` and `redirectUrl`, so you can find 404s, redirects and blocked pages listed in the sitemap. It falls back to `GET` when `HEAD` isn't allowed.
- **Reliable.** Retries with exponential backoff on 429 / 5xx / timeouts, resumes an interrupted download without duplicating URLs, and one broken site or sitemap never fails the whole run. A per-site summary tells you what was found and what went wrong.

### Use cases

- **SEO audits**: list every indexable URL, find pages that are in the sitemap but return 404 or redirect, check `lastmod` freshness, count images and hreflang alternates.
- **URL feeder for AI agents, RAG and crawlers**: get a clean list of a site's pages (optionally only `/docs/` or `/blog/`, or only pages changed in the last 7 days) and pass it to a content crawler.
- **Content monitoring**: schedule a daily run with `modifiedAfter: "1 day"` to get only new or updated pages, for example competitor blogs or news sites.
- **Site migrations**: export the full URL inventory before and after a migration and compare.

### Input example

```json
{
  "sites": ["example.com", "https://www.example.org/sitemap_index.xml"],
  "maxUrlsPerSite": 0,
  "includeUrlPatterns": ["/blog/"],
  "excludeUrlPatterns": ["/tag/", "/page/\\d+"],
  "modifiedAfter": "30 days",
  "checkStatus": false
}
```

| Field | Description |
|---|---|
| `sites` | Domains, homepages, or direct sitemap URLs (`.xml`, `.xml.gz`, `.txt`, RSS/Atom). |
| `discoveryMode` | `robots-then-common` (default), `robots-and-common`, `robots-only`, `common-only`. |
| `followSitemapIndexes` / `maxIndexDepth` | Follow nested sitemap indexes (default on, depth 5). |
| `maxUrlsPerSite` | Stop after N URLs per site (after filters). `0` = no limit. |
| `maxSitemapsPerSite` | Safety cap on sitemap files opened per site. `0` = no limit. |
| `includeUrlPatterns` / `excludeUrlPatterns` | Case-insensitive regular expressions. |
| `modifiedAfter` / `modifiedBefore` | Filter on `<lastmod>`: `2024-05-01` or `30 days`, `2 weeks`, `6 months`, `1 year`. |
| `keepUrlsWithoutLastmod` | Keep URLs without `<lastmod>` when a date filter is set (default off). |
| `deduplicate` | One record per URL per site (default on). |
| `checkStatus` / `statusConcurrency` | HEAD-check every URL (separate charge). |
| `includeSiteSummaries` | Also add one free summary row per site to the dataset. |
| `maxConcurrency` | Sites processed in parallel (default 5). |
| `proxyConfiguration` | Off by default. Turn on Apify Proxy only if a site blocks you. |

### Output example

One record per URL. Every record has the same fields; the ones that don't apply are `null` or empty.

```json
{
  "url": "https://www.example.com/news/big-story",
  "domain": "www.example.com",
  "site": "https://example.com",
  "sitemapUrl": "https://www.example.com/sitemaps/news.xml.gz",
  "lastmod": "2024-11-22T00:00:33.000Z",
  "changefreq": null,
  "priority": null,
  "imageCount": 1,
  "imageUrls": ["https://cdn.example.com/big-story.jpg"],
  "imageTitle": null,
  "videoCount": 0,
  "videoTitle": null,
  "videoDescription": null,
  "videoThumbnailUrl": null,
  "videoContentUrl": null,
  "videoPlayerUrl": null,
  "videoDuration": null,
  "videoPublicationDate": null,
  "newsTitle": "The big story",
  "newsPublicationName": "Example News",
  "newsLanguage": "en",
  "newsPublicationDate": "2024-11-22T00:00:32.000Z",
  "newsKeywords": null,
  "alternateCount": 0,
  "alternates": [],
  "statusCode": 200,
  "redirectUrl": null,
  "statusError": null,
  "scrapedAt": "2024-11-22T00:01:55.978Z"
}
```

`lastmod` and other dates are normalized to ISO 8601 when they can be parsed. Otherwise the original text is kept. `alternates` is a list of `{ "hreflang": "de", "href": "..." }`.

#### Per-site summary

The key-value store record **OUTPUT** holds one summary per site: how it was discovered (`robots.txt`, `common-paths`, `input`), the number of sitemaps and sitemap indexes found, failed sitemaps, URLs seen, filtered out, duplicates, total URLs returned, why it stopped (`max-urls-per-site`, `max-cost-reached`), and readable error messages such as "No sitemap found" or "returned HTTP 403". Turn on `includeSiteSummaries` to get the same rows in the dataset (`recordType: "site-summary"`, not charged).

### Pricing

Pay per event, no subscription:

| Event | Price |
|---|---|
| URL extracted (one dataset record) | **$0.00025** ($0.25 per 1,000 URLs) |
| URL status checked (only with `checkStatus`) | **$0.0003** ($0.30 per 1,000 URLs) |

Site summaries are free. Platform compute is very small because the actor uses plain HTTP and a streaming parser, and it runs in 256 MB of memory by default. Set **Max cost per run** in the run options to cap spending: the actor stops cleanly when the limit is reached and keeps everything extracted so far.

### FAQ

**Do I need to know where the sitemap is?** No. Just enter the domain. A URL with a normal page path (like `example.com/blog`) is treated as its domain; to read one specific sitemap, enter the sitemap file URL. If the sitemap is somewhere unusual and not listed in `robots.txt`, paste its URL directly.

**Does it crawl the website?** No. It only reads sitemaps (and `robots.txt`). Pages that aren't in any sitemap won't be returned. If you need those, use a crawler.

**How many URLs can it handle?** Millions. Sitemaps are streamed and de-duplication uses a compact hash set. In our test, 200,000 URLs from nytimes.com took about 3.5 minutes and peaked at 180 MB of memory with the default 256 MB. For sites with more than about 1M URLs, give the run 1 GB of memory, or turn off `deduplicate`.

**Why did a site return 0 URLs?** Look at the summary in OUTPUT. Common causes: the site has no sitemap, the sitemap is blocked (HTTP 403, so try enabling the proxy), or your filters removed everything.

**What does the status check do?** One `HEAD` request per URL, with redirects not followed. `statusCode` is the first response (for example 301), and `redirectUrl` is where it points. This is great for finding broken or redirected URLs in your sitemap. It is slower than extraction alone, and some sites rate-limit it, so lower `statusConcurrency` if you see many 429s.

**Can I get only new pages?** Yes. Use `modifiedAfter` (for example `"1 day"`) on a schedule. This relies on the site providing accurate `<lastmod>` values.

**Is the data personal?** No. Sitemaps are public files that site owners publish for search engines. The actor doesn't collect any personal data.

### Limits

- Only URLs listed in sitemaps or feeds are returned. This isn't a full crawler.
- `lastmod` filtering depends on the site's own `<lastmod>` values, which some sites omit or set to the crawl time.
- Sitemaps behind a login, or behind strong bot protection that blocks even a proxy, can't be read.
- A single sitemap file is capped at 500 MB uncompressed (the protocol limit is 50 MB).

# Actor input Schema

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

Domains (example.com), homepages (https://example.com) or direct sitemap URLs (https://example.com/sitemap.xml, .xml.gz, .txt, RSS/Atom). For a domain, sitemaps are discovered automatically from robots.txt and common paths. Leave empty to run a 20-URL demo on apify.com.

## `discoveryMode` (type: `string`):

How to find sitemaps when you give a domain. Default: read robots.txt 'Sitemap:' lines, and only if there are none, try common paths (/sitemap.xml, /sitemap_index.xml, /wp-sitemap.xml, /sitemap.xml.gz, news/image/video sitemaps...).

## `followSitemapIndexes` (type: `boolean`):

Recursively open child sitemaps listed in sitemap index files.

## `maxIndexDepth` (type: `integer`):

How many levels of nested sitemap indexes to follow.

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

Stop after this many URLs (after filters) for each site. 0 = no limit (millions are fine).

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

Safety limit on how many sitemap files are opened per site. 0 = no limit.

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

Keep only URLs matching at least one of these regular expressions (case-insensitive), e.g. /blog/ or .html$

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

Drop URLs matching any of these regular expressions (case-insensitive), e.g. /tag/ or ?

## `modifiedAfter` (type: `string`):

Keep only URLs whose <lastmod> is on/after this date. Absolute (2024-05-01) or relative (30 days, 2 weeks, 6 months).

## `modifiedBefore` (type: `string`):

Keep only URLs whose <lastmod> is on/before this date. Absolute or relative (e.g. 1 year).

## `keepUrlsWithoutLastmod` (type: `boolean`):

When a date filter is set, URLs that have no <lastmod> are dropped unless this is on.

## `deduplicate` (type: `boolean`):

Output each URL only once per site, even if it appears in several sitemaps.

## `checkStatus` (type: `boolean`):

Send a HEAD request to every extracted URL and add statusCode and redirectUrl (redirects are not followed). Charged as a separate event. Slower.

## `statusConcurrency` (type: `integer`):

Parallel HEAD requests per site. Lower it if the site rate-limits you.

## `includeSiteSummaries` (type: `boolean`):

Also push one summary row per site (recordType = site-summary) into the dataset. Summaries are always saved to the key-value store record OUTPUT. Summary rows are free.

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

How many websites are processed at the same time.

## `proxyConfiguration` (type: `object`):

Not needed for most sites. Enable Apify Proxy if a site blocks requests (HTTP 403/429).

## Actor input object example

```json
{
  "sites": [
    "https://apify.com"
  ],
  "discoveryMode": "robots-then-common",
  "followSitemapIndexes": true,
  "maxIndexDepth": 5,
  "maxUrlsPerSite": 20,
  "maxSitemapsPerSite": 0,
  "keepUrlsWithoutLastmod": false,
  "deduplicate": true,
  "checkStatus": false,
  "statusConcurrency": 10,
  "includeSiteSummaries": false,
  "maxConcurrency": 5,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

## `urls` (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 = {
    "sites": [
        "https://apify.com"
    ],
    "maxUrlsPerSite": 20,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("sharkinho/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://apify.com"],
    "maxUrlsPerSite": 20,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("sharkinho/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://apify.com"
  ],
  "maxUrlsPerSite": 20,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call sharkinho/sitemap-url-extractor --silent --output-dataset

```

## MCP server setup

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