# Sitemap Extractor & URL Finder (`urameshi7k/sitemap-extractor`) Actor

Get every URL from a website's sitemaps: auto-discovers them via robots.txt, follows nested sitemap indexes, reads gzip, text, RSS and Atom sitemaps, filters by URL pattern or last-modified date, and can return only the URLs that are new since the last run.

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

## Pricing

from $0.10 / 1,000 extracted 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 & URL Finder

Get all URLs of a website from its sitemaps, in seconds. Give it a domain and it finds the sitemaps for you (robots.txt first, then common locations), follows nested sitemap indexes, reads compressed and non-XML sitemaps, and returns a clean list of URLs with their last-modified dates, ready to export as CSV, JSON or Excel.

Turn on **Only new URLs** and schedule it: each run returns just the pages, products or articles that appeared since the previous run, and you pay only for those.

### What it does

- **Finds sitemaps automatically** from `robots.txt`, or from `/sitemap.xml`, `/sitemap_index.xml`, `/wp-sitemap.xml` and other common paths when robots.txt lists none.
- **Follows sitemap indexes** at any nesting depth, including split product sitemaps on Shopify, WordPress (Yoast, Rank Math, core) and large news sites.
- **Reads every common format:** XML, gzip (`.xml.gz`), plain-text sitemaps, and RSS and Atom feeds.
- **Keeps the useful details:** `lastmod` (normalized to UTC), `changefreq`, `priority`, image count and image URLs, `hreflang` language alternates, and Google News fields.
- **Survives broken sitemaps:** malformed XML (unescaped `&`, truncated files) is recovered with a tolerant parser instead of failing the run.
- **Filters before you pay:**
  - include or exclude URLs with regular expressions;
  - read only certain sitemaps, such as `post-sitemap` or `products`;
  - keep URLs modified after or before a date, or within a period like `7 days`.
- **Scopes to a section:** enter `https://example.com/blog/` to get only the URLs under `/blog/`.
- **Monitors for new URLs:** remembers the URLs it has seen and returns only the others. New URLs a run could not return, because of *Max URLs* or your cost limit, come back on the next run, unless your filters exclude them by then (a period in *Modified after* moves with each run).

### How to get all URLs of a website

1. Enter the website in **Websites or sitemap URLs**, for example `example.com`. To list one section only, enter its address, such as `https://www.example.com/blog/`.
2. Optionally narrow it down with URL patterns, specific sitemaps or a date.
3. Click **Start**. The extractor finds the site's sitemaps and lists every page they contain.
4. Download the URL list as CSV, JSON or Excel, or read it through the API.

### Export a sitemap to CSV, JSON or Excel

Already know the sitemap address? Enter it directly, for example `https://www.example.com/sitemap.xml` or a `.xml.gz` file. Nested sitemap indexes are followed, and every URL becomes one row with its `lastmod`, `changefreq` and `priority`. Pick the format when you export the results: CSV and Excel for spreadsheets, JSON for code.

### Use cases

- **SEO audits and content inventories:** export every indexable URL with its last-modified date.
- **Crawling and AI/RAG pipelines:** feed a clean URL list to a crawler instead of discovering links page by page.
- **Competitor monitoring:** schedule a daily run with *Only new URLs* to see new products, landing pages or blog posts the day they are published.
- **Site migrations and QA:** compare the URLs a site advertises before and after a release.
- **News and content tracking:** use *Modified after* = `24 hours` on news sitemaps to collect fresh articles.

### Input examples

Extract all URLs of two sites:

```json
{
  "startUrls": ["apify.com", "https://www.example.com"]
}
```

Blog posts changed in the last 30 days, without tag and author pages:

```json
{
  "startUrls": ["https://www.example.com"],
  "includeUrlPatterns": ["/blog/"],
  "excludeUrlPatterns": ["/tag/", "/author/"],
  "modifiedAfter": "30 days"
}
```

Daily monitor of new product pages (schedule this run in Apify):

```json
{
  "startUrls": ["https://shop.example.com"],
  "sitemapUrlPatterns": ["product"],
  "onlyNewUrls": true,
  "monitoringName": "competitor-shop-products"
}
```

The first monitoring run only saves a baseline: it returns nothing and charges nothing for URLs. Every later run returns only new URLs, each marked with `"isNew": true`. If the baseline could not read a sitemap, or a site at all, its status message says so, and the next run that reads it adds its URLs to the baseline instead of returning them. Turn off **First run only saves a baseline** if you also want the current URLs on the first run.

### Output

One dataset item per URL:

```json
{
  "url": "https://www.example.com/products/wool-runner",
  "lastmod": "2026-11-16T11:37:38Z",
  "changefreq": "daily",
  "priority": null,
  "sitemapUrl": "https://www.example.com/sitemap_products_1.xml",
  "site": "https://www.example.com",
  "sourceType": "xml",
  "imageCount": 1,
  "alternates": [{ "hreflang": "pt-br", "href": "https://www.example.com/pt/products/wool-runner" }]
}
```

Optional fields:

- `imageUrls`, when **Include image URLs** is on;
- `news`, with the title, publication date, publication name and language;
- `videoCount`;
- `isNew`, in monitoring mode.

Download the results as JSON, CSV, Excel or HTML, or read them through the Apify API.

A run summary is saved in the key-value store as `OUTPUT`. For each site it lists:

- the sitemaps it found and read;
- the sitemaps (or robots.txt) that failed, and why;
- how many URLs were found, filtered out, already known or returned (the run's total `urlsFound` counts a URL once, even when several start URLs read it);
- whether the run stopped early.

### Sitemap extractor API and integrations

Start a run and get the URLs in one HTTP call (it waits up to 5 minutes, enough for most sites):

```bash
curl -X POST "https://api.apify.com/v2/acts/urameshi7k~sitemap-extractor/run-sync-get-dataset-items?token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"startUrls": ["https://www.example.com"], "maxUrls": 1000}'
```

The response is the list of URLs as JSON. Add `&format=csv` to the address to get CSV instead. The **API** tab shows ready-made code for the Python and JavaScript clients.

You can also:

- **schedule** runs, for example a daily list of new pages with *Only new URLs*;
- send results to **Make, Zapier, n8n, Google Drive or Slack**, or call your own **webhook** when a run finishes;
- give **AI agents** this tool through the Apify MCP server: add `https://mcp.apify.com?tools=urameshi7k/sitemap-extractor` to your MCP client.

### Pricing

You pay per URL returned, from $0.10 to $0.40 per 1,000 URLs depending on your Apify plan (see the Pricing tab), plus a very small fee for every 100 URLs read from sitemaps (about $0.10 per million URLs). That fee covers downloading and parsing when filters or monitoring return only a few URLs. Date limits skip whole sitemaps, so they make runs cheaper. In monitoring mode, the per-URL price applies only to new URLs.

Set a **maximum cost per run** in the run options. The Actor stops cleanly before it would go over that limit. With *Only new URLs*, the new URLs it could not return come back on the next run, unless your filters exclude them by then. **Max URLs per run** defaults to 100,000, because some sites list millions of URLs. Raise it, or set it to 0, when you need everything.

### Tips

- **No sitemap found?** Some sites don't publish one. If you know the sitemap address, enter it directly, for example `https://example.com/sitemaps/main.xml`.
- **Large sites:** a date filter skips whole child sitemaps whose own `lastmod` is older, which saves time on news sites with years of archives. With *Only new URLs*, pages in skipped sitemaps are not remembered, so an old page that gets updated comes back as new.
- **Memory:** the default 1 GB handles sites with about 3 million URLs, even in monitoring mode. On Apify, more memory also means more CPU, so very large sites finish faster with 2–4 GB at a similar cost.
- **Separate monitors:** runs that share a **Monitoring name** share their memory of known URLs. Use different names to track different lists of sites. Without a name, the list of start URLs identifies the monitor.

### FAQ

**How do I find all pages on a website?**
Enter the website and start the run. The extractor reads the sitemaps the site publishes for search engines and returns every page they list. Pages that no sitemap lists are not included.

**How do I convert a sitemap XML to CSV?**
Enter the sitemap address (or just the website), run it, and export the results as CSV. Each URL becomes one row.

**Can I use it through an API?**
Yes. Every run can be started through the Apify API and returns the URLs as JSON or CSV. See *Sitemap extractor API and integrations* above.

**Does it load pages or run JavaScript?**
No. It reads only `robots.txt` and the sitemap files, which sites publish precisely so that crawlers can find their pages. That's why it is fast and cheap.

**How polite is it?**
It downloads at most five files from the same site at a time, identifies itself with a clear user agent, and retries temporary errors (429 and 5xx) with a pause.

**Is it legal to use?**
Sitemaps are public files intended for automated discovery. You are responsible for how you use the URLs and any content you collect afterwards, including the target site's terms and applicable laws.

**A sitemap failed. What now?**
Check `OUTPUT` → `sites` → `sitemapsFailed` for the URL and the reason (HTTP status, invalid URL, not a sitemap, too large). Other sitemaps of the same site are still processed.

### Related Actors

- [Website Screenshot Crawler](https://apify.com/urameshi7k/website-screenshot-crawler): screenshot every page of a website, full page on desktop and mobile, with an HTML gallery.

# Actor input Schema

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

Websites (example.com or https://example.com) or direct sitemap URLs (.xml, .xml.gz, .txt, RSS or Atom). For websites, sitemaps are found through robots.txt and, when it lists none, through common locations such as /sitemap.xml and /wp-sitemap.xml. A page with a path, such as https://example.com/blog/, returns only URLs under that path.

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

Stop after this many URLs in total. Some sites list millions of URLs, so the default is 100,000. Set 0 for no limit (the run still stops at the maximum cost you set for it).

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

Stop reading a site after this many URLs. 0 = no limit.

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

Keep only URLs that match at least one of these regular expressions (case-insensitive). Examples: /blog/ or /products/ or .pdf$

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

Drop URLs that match any of these regular expressions (case-insensitive). Example: /tag/ or ?page=

## `sitemapUrlPatterns` (type: `array`):

Read URLs only from sitemaps whose own URL matches one of these regular expressions, for example post-sitemap or product. Sitemap index files are always followed.

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

Keep URLs whose lastmod (in news sitemaps, the publication date) is on or after this moment. Use a date (2025-01-31), a full ISO date-time, or a period counted back from the start of the run, such as "7 days" or "24 hours". Child sitemaps whose own lastmod is older are skipped, which makes runs on large sites much faster.

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

Keep URLs whose lastmod (or news publication date) is on or before this moment. Same formats as above.

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

When a date filter is set, also keep URLs that have no date (no lastmod or news publication date), and read every child sitemap.

## `sameSiteOnly` (type: `boolean`):

Drop URLs whose host differs from the start URL's host (a leading www. is ignored).

## `onlyNewUrls` (type: `boolean`):

Return only URLs that are new to this monitor: earlier runs did not return them or save them as known. Ideal for scheduled runs that watch competitors for new pages, products or articles: you pay only for new URLs. New URLs a run could not return (Max URLs, cost limit) come back on the next run, unless your filters exclude them by then (a period in Modified after moves with each run). With Modified after, sitemaps skipped as old are not read, so their pages count as new once they are updated.

## `monitoringName` (type: `string`):

Optional name for the saved list of known URLs. Runs that use the same name share it. By default the name is derived from the list of start URLs.

## `baselineOnFirstRun` (type: `boolean`):

On the first monitoring run, save the current URLs without returning (or charging for) them. Turn off to receive every URL on the first run.

## `includeImageUrls` (type: `boolean`):

Add the image URLs listed in image sitemaps. The number of images is always included.

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

Add alternate language versions (hreflang links) when the sitemap lists them.

## `maxSitemapDepth` (type: `integer`):

How many levels of nested sitemap index files to follow.

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

Maximum simultaneous downloads in total. At most 5 go to the same site at once.

## `requestTimeoutSecs` (type: `integer`):

How long to wait for each sitemap download before retrying.

## Actor input object example

```json
{
  "startUrls": [
    "https://apify.com"
  ],
  "maxUrls": 1000,
  "maxUrlsPerSite": 0,
  "keepUrlsWithoutLastmod": false,
  "sameSiteOnly": false,
  "onlyNewUrls": false,
  "baselineOnFirstRun": true,
  "includeImageUrls": false,
  "includeAlternates": true,
  "maxSitemapDepth": 5,
  "maxConcurrency": 10,
  "requestTimeoutSecs": 30
}
```

# Actor output Schema

## `urls` (type: `string`):

One item per URL found in the sitemaps, with lastmod, changefreq, priority, the sitemap it came from and optional image, language and news details.

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

Per-site report: sitemaps found and read, failures with reasons, URL counts and whether the run stopped early.

# 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": [
        "https://apify.com"
    ],
    "maxUrls": 1000
};

// Run the Actor and wait for it to finish
const run = await client.actor("urameshi7k/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 = {
    "startUrls": ["https://apify.com"],
    "maxUrls": 1000,
}

# Run the Actor and wait for it to finish
run = client.actor("urameshi7k/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 '{
  "startUrls": [
    "https://apify.com"
  ],
  "maxUrls": 1000
}' |
apify call urameshi7k/sitemap-extractor --silent --output-dataset

```

## MCP server setup

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