# Sitemap URL Extractor: Get All Website URLs from sitemap.xml (`delgadolegacy/sitemap-url-extractor`) Actor

Extract every URL from a website's sitemap.xml: auto-discovers sitemaps via robots.txt, follows sitemap indexes, .gz and text sitemaps, returns lastmod, changefreq, priority, hreflang and image counts. Regex and date filters. Obeys robots.txt. From $0.08 per 1,000 URLs.

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

## Pricing

from $0.08 / 1,000 url results

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 URL Extractor: Get All Website URLs from sitemap.xml

**Sitemap URL Extractor** pulls **every URL from a website's XML sitemap** into a clean JSON, CSV or Excel list. Give it a domain and it **auto-discovers sitemaps from robots.txt** (and common paths like `/sitemap.xml`, `/sitemap_index.xml`, `/wp-sitemap.xml`), follows **sitemap indexes**, reads **gzipped `.xml.gz`** and **plain-text sitemaps**, and returns each page's **lastmod, changefreq, priority, hreflang alternates, image count** and Google News title/date. Filter by **regex** or **last-modified date**. No login, no proxies, no browser. **Pay per result from $0.08 per 1,000 URLs, no start fee.**

### Why use this sitemap extractor

- ✅ **Just type a domain**: sitemaps are found for you via robots.txt `Sitemap:` lines, with fallbacks.
- ✅ **Handles real-world sitemaps**: nested sitemap indexes, `.gz` files, text sitemaps, image/news/hreflang extensions.
- ✅ **Filters that save money**: include/exclude regex (`/blog/`, `/products/`) and *modified since* date, applied before anything is saved.
- ✅ **Reliable and fast**: plain HTTP, no headless browser; thousands of URLs in seconds, with safety caps so runs don't hang.
- ✅ **Polite by design**: obeys robots.txt and `Crawl-delay`, identifies itself with a clear user agent.
- ✅ **Pay only for results**: $0.40 per 1,000 URLs on the Free plan, down to $0.08 on Gold+. No start fee.

### Use cases

- **SEO audits**: list every indexed page, find stale pages by `lastmod`, check hreflang coverage.
- **Content inventory and migrations**: export all URLs before a redesign or CMS move.
- **Competitor monitoring**: schedule it daily with *modified since* to see new or updated pages.
- **Crawler seeding**: feed the URL list into Website Content Crawler, RAG pipelines or your own scraper.
- **Ecommerce**: list all product or category URLs with an include pattern.

### How to extract URLs from a sitemap

1. Add one or more websites (`https://example.com`) or direct sitemap URLs.
2. Optional: add include/exclude regex patterns or a *modified since* date.
3. Click **Start** and export the results as JSON, CSV or Excel, or use the API.

An empty input `{}` runs a demo on `https://www.usa.gov` (public U.S. government site).

### Input example

```json
{
  "startUrls": [{"url": "https://www.irs.gov"}],
  "includePatterns": ["/newsroom/"],
  "modifiedSince": "2026-01-01",
  "maxUrls": 3000
}
```

| Field | What it does |
|---|---|
| `startUrls` | Domains/homepages (auto-discovery) or direct sitemap URLs (.xml, .xml.gz, .txt, index) |
| `maxUrls` | Total URL cap for the run (0 = no limit) |
| `includePatterns` / `excludePatterns` | Regex filters on the URL |
| `modifiedSince` | Keep only URLs with `lastmod` on/after this date |
| `includeAlternates` | Add hreflang alternate URLs |
| `maxSitemaps` | Safety cap on sitemap files per site (default 200) |

### Sample results (real rows from our test run on irs.gov, Oct 24, 2026)

| URL | lastmod | changefreq | priority | hreflang alternates |
|---|---|---|---|---|
| https://www.irs.gov/newsroom | 2026-09-25T14:32:07-04:00 | weekly | 1.0 | 3 |
| https://www.irs.gov/newsroom/irs-doing-a-paycheck-checkup-is-a-good-idea-for-workers-with-multiple-jobs | 2026-03-26T18:28:53-04:00 | monthly | 0.8 | 6 |
| https://www.irs.gov/newsroom/tax-professionals-should-review-data-safeguards | 2026-08-24T23:44:14-04:00 | monthly | 0.8 | 2 |
| https://www.irs.gov/zh-hans/newsroom/tax-basics-understanding-the-difference-between-standard-and-itemized-deductions | 2026-08-24T23:48:57-04:00 | monthly | 0.8 | 3 |

That run read 12 sitemap files (found via robots.txt) and saved 3,000 matching URLs in about 5 seconds.

### Output example

```json
{
  "url": "https://www.irs.gov/es/newsroom",
  "domain": "www.irs.gov",
  "path": "/es/newsroom",
  "lastmod": "2026-09-25T14:32:07-04:00",
  "changefreq": "weekly",
  "priority": 1.0,
  "imageCount": 0,
  "alternates": [{"hreflang": "en", "url": "https://www.irs.gov/newsroom"}, {"hreflang": "es", "url": "https://www.irs.gov/es/newsroom"}],
  "newsTitle": null,
  "newsPublished": null,
  "sitemapUrl": "https://www.irs.gov/sitemap.xml?page=8",
  "site": "www.irs.gov"
}
```

A `RUN_SUMMARY` record lists, per site, where sitemaps were discovered, how many files were read, URLs saved, anything skipped by robots.txt, and errors.

### Pricing

**Pay per result**, live since Oct 24, 2026: you pay only for URLs saved to the dataset. No start fee, no monthly rental.

| Apify plan | Price per 1,000 URLs |
|---|---|
| Free | $0.40 |
| Bronze | $0.25 |
| Silver | $0.15 |
| Gold, Platinum, Diamond | $0.08 |

Apify platform usage is included. Set *Maximum cost per run* in the run options to cap spend; the run stops charging at your limit.

### FAQ

**The site has no sitemap. What happens?** The run finishes with 0 URLs and the RUN_SUMMARY says which locations were checked. This Actor reads sitemaps only; it does not crawl pages.

**Does it respect robots.txt?** Yes. Sitemap files disallowed for crawlers are skipped and `Crawl-delay` is obeyed.

**Can I process many websites?** Yes, add as many start URLs as you like; `maxUrls` is a total cap for the run.

**Is this legal?** Sitemaps are files that site owners publish specifically so automated crawlers can find their pages. You are responsible for how you use the URLs and any content you later fetch from them; check each site's terms.

**Found a bug or need a field?** Open an issue on the Issues tab.

### More free tools from the same developer

- [Career Page Jobs Scraper](https://apify.com/delgadolegacy/career-page-jobs-scraper): every open job from company career pages on Greenhouse, Lever, Ashby and Workable in one dataset.
- [SAM.gov Contract Opportunities](https://apify.com/delgadolegacy/samgov-opportunities): federal bids and solicitations from SAM.gov's official public data, no API key.
- [Remote Jobs Aggregator](https://apify.com/delgadolegacy/remote-jobs-aggregator): remote jobs from We Work Remotely and Remote OK, deduplicated, with salary and a new-jobs monitor.
- [PDF Text Extractor](https://apify.com/delgadolegacy/pdf-text-extractor): text, per-page text, keyword hits and metadata from PDF URLs in bulk, no start fee.

# Actor input Schema

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

A homepage/domain (sitemaps are found via robots.txt and common paths) or a direct sitemap URL (.xml, .xml.gz, .txt or a sitemap index).

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

Stop after this many URLs in total (0 = no limit).

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

Keep only URLs matching at least one regex, e.g. '/blog/' or '/products/.\*'.

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

Drop URLs matching any of these regexes, e.g. '/tag/' or '?page='.

## `modifiedSince` (type: `string`):

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

## `includeAlternates` (type: `boolean`):

Add the language/region alternate URLs listed for each page.

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

Safety cap on how many sitemap files are read per website.

## `respectRobotsTxt` (type: `boolean`):

Always on: sitemap files disallowed by robots.txt are skipped and Crawl-delay is obeyed.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.usa.gov"
    }
  ],
  "maxUrls": 500,
  "includeAlternates": true,
  "maxSitemaps": 200,
  "respectRobotsTxt": true
}
```

# Actor output Schema

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

One item per URL found in the sitemaps.

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

Sitemaps read, requests, robots.txt skips, errors per site.

# 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.usa.gov"
        }
    ],
    "maxUrls": 500
};

// Run the Actor and wait for it to finish
const run = await client.actor("delgadolegacy/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.usa.gov" }],
    "maxUrls": 500,
}

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

```

## MCP server setup

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