# Sitemap URL Extractor (`plainpipe/sitemap-url-extractor`) Actor

Extract page URLs from a website's XML sitemaps with lastmod, changefreq, priority. Use when you need a site's full URL list, filtered by URL pattern or date.

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

## Pricing

$0.50 / 1,000 results

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

Extract every page URL from a website's XML sitemaps, with lastmod, changefreq and priority. Finds sitemaps via robots.txt and follows sitemap indexes.

**Use this when:** you need the list of page URLs a website publishes in its sitemaps, optionally only the ones matching a URL pattern or a lastmod date range.

### Why this one

- $0.50 per 1,000 returned URLs; sitemap index entries, failed fetches and filtered-out URLs are free.
- Filter by URL pattern and lastmod date — you pay only for the URLs you keep.
- Each row carries `lastmod`, `changefreq`, `priority` and the exact sitemap file it came from; `.xml.gz` sitemaps and sitemap indexes are handled.
- Plain HTTP requests only: no browser, no proxy. The prefilled input is run as an automated test daily.

### What it does

Give it one or more websites. For each site it reads robots.txt to find the declared sitemaps, falls back to the usual locations (`/sitemap.xml`, `/sitemap_index.xml`, `/sitemap-index.xml`, `/wp-sitemap.xml`, `/sitemap.xml.gz`), follows sitemap index files down to the real URL lists, and unpacks `.xml.gz` sitemaps. You get one row per page URL with the `lastmod`, `changefreq` and `priority` the sitemap declares, plus the sitemap file it came from.

### Use cases

- Build a clean list of every page on a site before an SEO audit, a migration or a content inventory.
- Find stale pages: set `lastmodBefore` (with `requireLastmod`) to get only URLs that have not been updated for years.
- Track a public page inventory over time by running the Actor on a schedule and comparing the URL lists.
- Feed the URL list into another tool, for example an on-page audit, an indexability check or your own crawler.
- Check that a new section or a batch of new posts actually made it into the sitemap.

### How to use it

1. Add one or more websites to **Websites**, one per line (a full URL or just the domain, e.g. `example.com`).
2. Optionally paste sitemap file URLs into **Sitemap URLs** to skip discovery.
3. Set **Max results** to cap the number of URLs, and with it the cost.
4. Run the Actor. Results land in the dataset; export them as JSON, CSV or Excel, or read them through the Apify API.

### Input

| Field | What it is | Default | Example |
|---|---|---|---|
| `sites` (required) | Websites to read. Invalid entries are skipped with a log warning. | none | `["example.com", "https://www.example.org"]` |
| `sitemapUrls` | Sitemap files to read directly (XML or `.xml.gz`), instead of discovery. Indexes are followed. | empty (discover automatically) | `["https://example.com/post-sitemap.xml"]` |
| `includePatterns` | Keep only URLs matching at least one pattern. Plain text or regular expression, case-insensitive. An invalid regular expression fails the run with 0 results. | empty (keep all) | `["/blog/"]` |
| `excludePatterns` | Drop URLs matching any pattern (plain text or regular expression, case-insensitive). | empty | `["/tag/", "\\?page="]` |
| `lastmodAfter` | Keep only URLs with `lastmod` on or after this ISO date. | none | `"2024-01-01"` |
| `lastmodBefore` | Keep only URLs with `lastmod` before this ISO date (find stale pages). | none | `"2023-01-01"` |
| `requireLastmod` | Drop URLs that have no `lastmod`. Without it, such URLs pass the date filters. | `false` | `true` |
| `maxItems` | Stop after this many returned page URLs in total (filtered-out URLs do not count). | `1000` | `5000` |

Example input:

```json
{ "sites": ["https://apify.com"], "maxItems": 50 }
```

Only blog posts changed since 2024, skipping tag pages:

```json
{ "sites": ["example.com"], "includePatterns": ["/blog/"], "excludePatterns": ["/tag/"], "lastmodAfter": "2024-01-01" }
```

Filtered-out URLs are not returned and not charged.

### Output

One result per page URL found in a sitemap. Real rows from a run on `https://apify.com`:

```json
[
  {
    "url": "https://apify.com/",
    "lastmod": null,
    "changefreq": null,
    "priority": null,
    "sitemap": "https://apify.com/sitemap/pages.xml",
    "site": "https://apify.com"
  },
  {
    "url": "https://apify.com/about",
    "lastmod": null,
    "changefreq": null,
    "priority": null,
    "sitemap": "https://apify.com/sitemap/pages.xml",
    "site": "https://apify.com"
  }
]
```

| Field | Meaning |
|---|---|
| `url` | The page URL listed in the sitemap (`<loc>`). |
| `lastmod` | Last modification date as the sitemap states it, or `null`. |
| `changefreq` | Declared change frequency (`daily`, `weekly`, ...), or `null`. |
| `priority` | Declared priority as a number from 0 to 1, or `null`. |
| `sitemap` | The sitemap file the URL was read from. |
| `site` | The website from your input. |

Fields a sitemap does not provide come back as `null`.

### Pricing

Pay per result: **$0.50 per 1,000 results** ($0.0005 per result). You only pay for page URLs the Actor returns; sitemap index entries, failed fetches and URLs removed by your filters are free. Set a maximum total charge on the run to cap your spend.

### Limits

- Reads up to 200 sitemap files per site.
- Only reads sitemaps; it does not crawl pages or follow links, so a page missing from the sitemap is missing from the output.
- One request at a time per site with a short pause between requests, so very large sitemap trees take a few minutes.
- If a site blocks automated requests or robots.txt disallows a sitemap path, that sitemap is skipped and noted in the log.
- An invalid regular expression in `includePatterns` / `excludePatterns`, or an unreadable date, fails the run at once with 0 results and a message naming the bad value.
- If no URL is found for any site (or every URL was filtered out), the run fails with zero results and a message that says what to check.

### FAQ

**How much does a run cost?** $0.50 per 1,000 URLs returned. A site with 10,000 URLs in its sitemaps costs about $5. Use **Max results** to set a hard cap.

**The run failed with "No page URLs found". What now?** The site has no sitemap the Actor could find or read. Open `https://<site>/robots.txt` and `https://<site>/sitemap.xml` in a browser; if the sitemap lives somewhere else, paste its URL into **Sitemap URLs**.

**Can I run it on a schedule or from my own code?** Yes. Use Apify Schedules to run it daily or weekly, and the Apify API or integrations (webhooks, Zapier, Make, spreadsheet tools) to pull the dataset into your tools.

**Need to check the pages you found?** See Plain Pipe's SEO Page Audit & On-Page Checker for on-page tags, or Plain Pipe's Indexability Checker (noindex, robots.txt) to see which URLs search engines may index.

### Legal and data

This Actor processes only public, non-personal technical data: the sitemap files a website publishes for search engines. It respects robots.txt, sends an honest user agent, does not log in anywhere, does not collect personal data, and does not bypass paywalls, CAPTCHAs or access controls. You are responsible for having the right to process the inputs you provide.

### Support

Open an issue on the Issues tab. Issues are answered within 14 days.

Built and maintained by Plain Pipe.

# Actor input Schema

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

Websites to read, one per line: a domain or full URL, e.g. "example.com" or "https://www.example.com". The Actor finds each site's sitemaps through robots.txt and the usual paths (/sitemap.xml, /sitemap_index.xml, /wp-sitemap.xml), then follows sitemap indexes. Invalid entries are skipped with a log warning.

## `sitemapUrls` (type: `array`):

Optional. Full URLs of sitemap files (XML or .xml.gz) to read directly instead of discovering them, e.g. "https://example.com/post-sitemap.xml". Sitemap indexes are followed. Leave empty to discover sitemaps automatically.

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

Optional. Keep only page URLs that match at least one of these patterns. Each pattern is plain text matched anywhere in the URL, or a regular expression, case-insensitive, e.g. "/blog/" or "/blog/\d{4}/". An invalid regular expression fails the run before anything is fetched. Leave empty to keep all URLs.

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

Optional. Drop page URLs that match any of these patterns (plain text or regular expression, case-insensitive), e.g. "/tag/" or "\\?page=". Applied after Include URL patterns. Dropped URLs are not returned and not charged.

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

Optional. ISO date or date-time, e.g. "2024-01-01" or "2024-01-01T00:00:00Z". Keep only URLs whose sitemap lastmod is on or after this moment. URLs without a lastmod are kept unless "Require lastmod" is on.

## `lastmodBefore` (type: `string`):

Optional. ISO date or date-time, e.g. "2023-01-01". Keep only URLs whose sitemap lastmod is before this moment (useful to find stale pages). URLs without a lastmod are kept unless "Require lastmod" is on.

## `requireLastmod` (type: `boolean`):

If true, drop URLs whose sitemap entry has no readable lastmod date. Default false (such URLs are kept).

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

Stop after this many returned page URLs in total across all sites, e.g. 5000. Only URLs that pass the filters count. You are charged per returned result, so this also caps the cost. Default 1000.

## Actor input object example

```json
{
  "sites": [
    "https://apify.com"
  ],
  "sitemapUrls": [],
  "includePatterns": [],
  "excludePatterns": [],
  "requireLastmod": false,
  "maxItems": 50
}
```

# Actor output Schema

## `results` (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"
    ],
    "maxItems": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("plainpipe/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"],
    "maxItems": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("plainpipe/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"
  ],
  "maxItems": 50
}' |
apify call plainpipe/sitemap-url-extractor --silent --output-dataset

```

## MCP server setup

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