# Sitemap Extractor: XML Sitemap Scraper, URLs to CSV & Status (`actorfactory/sitemap-extractor`) Actor

Sitemap scraper that extracts every URL from any website's XML sitemaps to CSV, JSON or Excel: robots.txt discovery, sitemap indexes, .gz files, lastmod, hreflang, image and news data. Turn on the bulk HTTP status and redirect checker to flag broken and redirected URLs.

- **URL**: https://apify.com/actorfactory/sitemap-extractor.md
- **Developed by:** [Actor Factory](https://apify.com/actorfactory) (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

from $0.28 / 1,000 sitemap urls

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Extractor: XML Sitemap Scraper, URLs to CSV & Status

This **sitemap extractor and scraper** pulls every URL listed in a website's **XML sitemaps** in one run and exports **sitemap to CSV**, Excel or JSON. Give it domains (`example.com`) or direct sitemap URLs. It finds sitemaps through `robots.txt` `Sitemap:` lines and common paths (`/sitemap.xml`, `/sitemap_index.xml`, `/wp-sitemap.xml`, `/sitemap.xml.gz`, `/sitemap.txt` and more), follows **sitemap indexes** recursively, reads **`.xml.gz`** and plain-text sitemaps, and keeps the **lastmod, changefreq, priority, image, video, hreflang and Google News** data. Turn on **Check HTTP status** and it doubles as a **bulk HTTP status and redirect checker** for every URL in the sitemap. Use it for SEO URL inventories, site migrations, content audits, competitor research and crawler seed lists. No browser, no login, no proxy.

### Bulk HTTP status & redirect checker

With `checkStatus: true`, every extracted URL is requested and its row gets the live answer:

- **`status_code`** of the first response (200, 301, 404, ...) and **`final_status_code`** after redirects
- **`final_url`**, the full **`redirect_chain`** (`[{url, status}]` for every hop) and **`redirect_hops`**
- **`response_ms`**, the time to the response headers
- **`check_result`**: `ok`, `redirect`, `broken`, `unverified` or `skipped`, plus a simple **`is_broken`** flag and a **`check_error`** code when there was no clean answer

How it checks: a `HEAD` request first, confirmed with `GET` whenever a server answers `HEAD` with an error (many servers refuse `HEAD`). Redirects are followed one hop at a time, up to 10, with loop detection. Each site's `robots.txt` is obeyed, including for redirect targets, and `Crawl-delay` is honoured. Requests are paced per host (at most 2 at a time and about 6 per second), and the actor slows down on HTTP 429. Use `maxUrlsToCheck` to check only the first N URLs and save the rest as plain rows.

Typical uses: find sitemap URLs that 404 or redirect (both hurt crawl budget), verify a site migration's redirect map, and monitor a sitemap for broken pages on a schedule. Open the **Status check** view in the Output tab for a ready-made table.

### What sitemap data you get

| Field | Description |
|---|---|
| `url` | Page URL listed in the sitemap |
| `domain` | Hostname of the URL |
| `sitemap_url` | The sitemap file that listed this URL |
| `lastmod` | Last-modified value from the sitemap, if present |
| `changefreq` | Change frequency, if present |
| `priority` | Priority 0.0 to 1.0, if present |
| `image_count` | Number of images attached to the URL |
| `video_count` | Number of videos attached to the URL |
| `hreflang` | Alternate language/region versions: `[{hreflang, href}]` |
| `news_title`, `news_publication`, `news_publication_date` | Google News sitemap data, if present |
| `status_code`, `final_status_code` | First and final HTTP status (only with **Check HTTP status**) |
| `final_url`, `redirect_chain`, `redirect_hops` | Where redirects lead, every hop as `{url, status}`, and the hop count |
| `response_ms` | Time to response headers, summed over hops |
| `check_result`, `is_broken`, `check_error` | `ok` / `redirect` / `broken` / `unverified` / `skipped`, a broken flag, and the error code when the check had no clean answer |
| `scraped_at` | When the data was collected (ISO 8601) |

### How to extract all URLs from a sitemap

| Input | Description |
|---|---|
| `sites` | Domains, page URLs or direct sitemap URLs, one per line |
| `includePattern` / `excludePattern` | Regex filters on the URL (case-insensitive) |
| `lastmodAfter` | Keep only URLs with lastmod on or after `YYYY-MM-DD` (URLs without lastmod are dropped) |
| `dedupe` | Output each URL once (default on) |
| `maxUrlsPerSite` | Per-site cap |
| `checkStatus` | Bulk HTTP status and redirect check of every saved URL (default off) |
| `maxUrlsToCheck` | Optional: status-check only the first N URLs; the rest are saved as plain rows |
| `maxItems` | Total cap across all sites. You are charged per URL saved |

```json
{
    "sites": ["https://crawlee.dev", "https://www.example.com/sitemap.xml"],
    "includePattern": "/docs/",
    "lastmodAfter": "2025-01-01",
    "maxItems": 1000
}
```

### Output example

```json
{
    "url": "https://www.nytimes.com/live/2026/11/14/us/example",
    "domain": "www.nytimes.com",
    "sitemap_url": "https://www.nytimes.com/sitemaps/new/news.xml.gz",
    "lastmod": "2026-11-14T16:37:19Z",
    "changefreq": null,
    "priority": null,
    "image_count": 1,
    "video_count": 0,
    "hreflang": [],
    "news_title": "Example headline",
    "news_publication": "The New York Times",
    "news_publication_date": "2026-11-14T10:45:54Z",
    "scraped_at": "2026-11-14T16:39:11.742Z"
}
```

With **Check HTTP status** on, each row also carries the check (example from crawler-test.com, a public test site for SEO crawlers):

```json
{
    "url": "https://crawler-test.com/redirects/redirect_3_302",
    "domain": "crawler-test.com",
    "sitemap_url": "https://crawler-test.com/test_sitemap.xml",
    "status_code": 302,
    "final_status_code": 200,
    "final_url": "https://crawler-test.com/redirects/redirect_target",
    "redirect_chain": [
        { "url": "https://crawler-test.com/redirects/redirect_3_302", "status": 302 },
        { "url": "https://crawler-test.com/redirects/redirect_2", "status": 301 },
        { "url": "https://crawler-test.com/redirects/redirect_1", "status": 301 }
    ],
    "redirect_hops": 3,
    "response_ms": 109,
    "check_result": "redirect",
    "is_broken": false,
    "check_error": null,
    "scraped_at": "2026-11-16T18:02:41.118Z"
}
```

### How much does it cost to extract sitemap URLs?

Pay per event: a tiny start fee plus **$0.40 per 1,000 URLs** saved. With **Check HTTP status** on, each checked URL is billed as **$1.00 per 1,000** instead, covering the extra requests. URLs that are not requested (skipped by `robots.txt`, or beyond `maxUrlsToCheck`) stay at the plain URL price. Volume discounts apply on higher Apify plans. Example: 50,000 URLs from a large site costs about $20; the same with status checks about $50.

### Use cases

- SEO URL inventory and sitemap vs. crawl comparisons
- Site migration planning: list every URL, then check status codes and redirects
- Content freshness: filter by `lastmod` to find recently changed pages
- Competitor research: see how many pages a site publishes and in which sections
- Seed lists for crawlers and scrapers

### Limits & notes

- Only sitemaps the site publishes are read. Pages missing from the sitemap are not found; this is not a crawler.
- Many sites omit `lastmod`; those URLs are dropped when `lastmodAfter` is set.
- Sites that block automated requests can return no sitemap. Pass the sitemap URL directly if discovery fails.
- Requests are paced per host (about 6 per second at most) and use one honest, fixed user agent (`SitemapExtractor/1.0`).
- The status check obeys `robots.txt` for the `SitemapExtractor` token (or `*`). Disallowed URLs are not requested and come back as `skipped`; if `robots.txt` itself is unreachable (5xx or network error), the site's URLs are skipped too, as RFC 9309 requires.
- Status checks are polite rather than fast: about 6 URLs per second per host, so 10,000 URLs from one site take roughly 30 minutes. The run stops taking new URLs shortly before its timeout and saves what it has.
- `401`, `403` and `429` answers are reported as `unverified`, not broken: the page may work in a browser.

### Integrations and API

Run it from your own code with the [Apify API](https://docs.apify.com/api/v2) or the official Python and JavaScript clients:

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("actorfactory/sitemap-extractor").call(run_input={
    "sites": ["https://crawlee.dev"],
    "checkStatus": True,      # bulk HTTP status and redirect check
    "maxUrlsToCheck": 500,    # optional cap on checked URLs
    "maxItems": 500,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    if item.get("is_broken") or item.get("redirect_hops"):
        print(item["status_code"], item["url"], "->", item["final_url"])
```

- **Schedule it** (hourly, daily, weekly) in Apify Console and send results to Google Sheets, Slack, email or a webhook, or connect it to Make, Zapier or n8n.
- **Use it from AI agents** (Claude, ChatGPT, Cursor) through the [Apify MCP server](https://mcp.apify.com).
- **Export** results as JSON, CSV, Excel or HTML from the Output tab, or read them from the dataset API.

### Related Actors

- [SEO Site Audit Crawler & Broken Link Checker](https://apify.com/actorfactory/seo-site-audit): full technical SEO crawl with broken links and an HTML report
- [Bulk Lighthouse Audit](https://apify.com/actorfactory/lighthouse-audit): Lighthouse performance, accessibility, best-practices and SEO scores plus Core Web Vitals lab metrics for a URL list or sitemap
- [App Store Scraper](https://apify.com/actorfactory/app-store-intelligence): App Store keyword rankings, app details and top charts

### FAQ

**Does it handle huge sites?** Yes. Sitemaps are read one at a time and results are saved in batches, so memory stays small. Use `maxUrlsPerSite` or `maxItems` to cap cost.

**What if a domain has no sitemap?** The run still succeeds with a clear status message and no charge.

**Are gzipped sitemaps supported?** Yes, `.xml.gz` files and gzip bodies are detected automatically.

**Can I use it as a bulk HTTP status or redirect checker?** Yes. Turn on **Check HTTP status**: every URL from the sitemap gets its status code, final URL, full redirect chain, response time and a broken flag. Filter on `check_result` (`broken`, `redirect`) or use the **Status check** view to find sitemap URLs that 404 or redirect. To check a list of URLs that is not in a sitemap, use the [SEO Site Audit Crawler & Broken Link Checker](https://apify.com/actorfactory/seo-site-audit) with **Crawl links** turned off.

**Why is a URL `unverified` or `skipped`?** `unverified` means the server gave no definitive answer: it refused access (401/403), rate-limited us (429), timed out or dropped the connection. `skipped` means the URL was not requested because the site's `robots.txt` disallows it (`check_error` says which). Skipped URLs are billed at the plain URL price.

**Can I export the sitemap URLs to CSV or Excel?** Yes. Download the dataset from the Output tab as CSV, Excel or JSON, or read it with the Apify API.

# Actor input Schema

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

Domains, page URLs or direct sitemap URLs, one per line. A domain (example.com) is resolved through robots.txt 'Sitemap:' lines and common paths like /sitemap.xml, /sitemap_index.xml and /wp-sitemap.xml. A direct sitemap URL (https://example.com/sitemap.xml or .xml.gz) is read as it is. Sitemap indexes are followed recursively.

## `includePattern` (type: `string`):

Optional regular expression (case-insensitive). Only URLs that match are kept. Example: /blog/ or .html$.

## `excludePattern` (type: `string`):

Optional regular expression (case-insensitive). URLs that match are dropped. Example: /tag/|/author/.

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

Optional date, YYYY-MM-DD. Only URLs whose sitemap lastmod is on or after this date are kept. URLs without a lastmod are dropped when this is set. Example: 2025-01-31.

## `dedupe` (type: `boolean`):

Output each URL once even if several sitemaps (or sites) list it.

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

Optional. Stop reading a site after this many sitemap URLs (before filters are applied to later ones). Leave empty for no per-site limit.

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

Bulk HTTP status and redirect check: request each URL (HEAD, confirmed with GET when a server refuses HEAD), follow redirects hop by hop and add status_code, final_status_code, final_url, redirect_chain, redirect_hops, response_ms, check_result (ok, redirect, broken, unverified, skipped), is_broken and check_error. Obeys each site's robots.txt and paces requests per host. Checked URLs are charged as a separate, higher-priced event.

## `maxUrlsToCheck` (type: `integer`):

Optional, used with Check HTTP status. Only the first this many saved URLs are checked; the rest are still saved, without status fields, at the plain URL price. Leave empty to check every saved URL.

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

Stop after this many URLs across all sites. You are charged per URL saved.

## Actor input object example

```json
{
  "sites": [
    "https://www.sitemaps.org",
    "https://crawlee.dev"
  ],
  "dedupe": true,
  "checkStatus": false,
  "maxItems": 10
}
```

# Actor output Schema

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

The scraped items in the default dataset.

## `statusCheck` (type: `string`):

The same items in the status-check view: status codes, redirects and broken URLs (filled when Check HTTP status is on).

## `summary` (type: `string`):

Counts, stop reason and non-fatal errors for this run (OUTPUT record).

# 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://www.sitemaps.org",
        "https://crawlee.dev"
    ],
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("actorfactory/sitemap-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://www.sitemaps.org",
        "https://crawlee.dev",
    ],
    "maxItems": 10,
}

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

```

## MCP server setup

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