# Sitemap URL Extractor & Scraper — indexes, gzip, robots.txt (`dropin-apis/sitemap-url-extractor`) Actor

Sitemap scraper that extracts page URLs from public XML sitemaps. Discovers robots.txt, sitemap.xml and sitemap indexes, unpacks gzip, and filters by date or regex. $0.40 per 1,000 URLs.

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

## Pricing

from $0.40 / 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 & Scraper — indexes, gzip, robots.txt

**Sitemap URL extractor and scraper** that reads a site's public sitemap — including sitemap indexes and gzip — and returns one row per page URL. It does not open those pages. $0.40 per 1,000 URLs.

Last updated: 2026-10-02.

Give it a domain or a sitemap URL. It looks up `robots.txt`, `/sitemap.xml` and `/sitemap_index.xml`, follows a sitemap index, and unpacks `.xml.gz`.

### Use cases

- **A URL list for another Actor.** Feed the rows into a crawler that only needs the links, not a fresh crawl of the whole site.
- **Change detection.** Keep rows whose `lastmod` is after a date you pass in.
- **A scoped export.** Keep or drop URLs with a regular expression (`/blog/`, a locale, a file type).

### Input

| Field | Type | Description |
|---|---|---|
| `startUrls` | array (required) | A domain (`example.com` or `https://example.com`) or a sitemap URL (`.xml` or `.xml.gz`). |
| `includeRegex` | string (optional) | Case-insensitive regular expression. Only matching URLs are kept. |
| `excludeRegex` | string (optional) | Case-insensitive regular expression. Matching URLs are dropped. |
| `lastmodSince` | string (optional) | ISO date. URLs with an older `lastmod` are dropped. URLs with no `lastmod` are kept. |
| `maxUrls` | integer | Stop after this many unique URLs. Default 1000. The Store's daily test uses 10. |

Example input:

```json
{
  "startUrls": [{ "url": "https://www.sitemaps.org" }],
  "maxUrls": 10
}
```

### Output

One dataset row per unique page URL.

```json
{
  "url": "https://www.sitemaps.org/",
  "lastmod": "2016-11-21",
  "changefreq": null,
  "priority": null,
  "sourceSitemap": "https://www.sitemaps.org/sitemap.xml",
  "domain": "www.sitemaps.org"
}
```

### Pricing

Pay per event. The primary event is `apify-default-dataset-item` at **$0.0004** per URL (**$0.40 per 1,000**). Apify charges it when a row is saved. There is no monthly fee.

### Limits

- Public `http` and `https` sitemaps only. No login, and private hosts (localhost, `10.x`, `192.168.x`) are refused.
- At most **50** sitemap files per run, and **20 MB** per file after unpacking.
- At most **5** fetches in flight, with retries on HTTP 429 and 5xx. `Crawl-delay` in robots.txt is honored up to 5 seconds.
- A path `Disallow`ed for `User-agent: *` is not fetched.
- The run **fails** if every input produces zero URLs, so an empty success is not reported as a finished dataset.

### FAQ

#### Does this crawl the pages listed in the sitemap?

No. It only downloads sitemap files and returns the URLs inside them.

#### What if the site publishes a sitemap index or a `.gz` file?

An index is followed, one child file at a time, until `maxUrls` is reached. A file that starts with the gzip magic bytes is unpacked. Both were checked against live sites: `https://apify.com` (index) and `https://www.gnu.org` (a child `sitemap0.xml.gz`).

#### What does a domain input fetch?

`/robots.txt` (every `Sitemap:` line), then `/sitemap.xml` and `/sitemap_index.xml` if those were not already listed. A start URL that already ends in `.xml` or `.xml.gz` is fetched directly.

#### Why did the run fail with "0 URL(s)"?

None of the inputs had a readable public sitemap. A missing `/sitemap_index.xml` on its own is normal and is not a failure. The failure means every candidate was missing or was not sitemap XML.

# Actor input Schema

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

A domain (example.com or https://example.com) or a direct sitemap URL (.xml or .xml.gz). Domains are discovered from robots.txt, /sitemap.xml and /sitemap\_index.xml.

## `includeRegex` (type: `string`):

JavaScript regular expression, case-insensitive. A URL is kept only when it matches. Leave empty to keep every URL.

## `excludeRegex` (type: `string`):

JavaScript regular expression, case-insensitive. Matching URLs are dropped.

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

ISO date, for example 2024-01-01. URLs whose lastmod is older are dropped. URLs with no lastmod are kept.

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

Stop after this many unique URLs. Default 1000. The daily Store test uses 10.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.sitemaps.org"
    }
  ],
  "maxUrls": 10
}
```

# Actor output Schema

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

All items in the run's 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 = {
    "startUrls": [
        {
            "url": "https://www.sitemaps.org"
        }
    ],
    "maxUrls": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("dropin-apis/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": [{ "url": "https://www.sitemaps.org" }],
    "maxUrls": 10,
}

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

```

## MCP server setup

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