# Sitemap Finder · URLs from Any XML (`corent1robert/sitemap-detector`) Actor

Find and crawl XML sitemaps from any website. Follows sitemap
indexes, handles gzip, and exports every page URL with source
file and lastmod into a clean dataset. No config needed.

- **URL**: https://apify.com/corent1robert/sitemap-detector.md
- **Developed by:** [Corentin Robert](https://apify.com/corent1robert) (community)
- **Categories:** Automation, Developer tools, SEO tools
- **Stats:** 3 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.69 / 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.
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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Sitemap Finder & URL Extractor · Crawl Any XML Sitemap

Turn a list of websites into a **full URL inventory** from their XML sitemaps—no manual `sitemap.xml` links, no knobs to tune. The actor discovers sitemaps for you, walks **sitemap indexes**, handles **gzip**, and writes a tidy dataset: every page URL, the **source sitemap file**, and **`lastmod`** when the site publishes it.

**Built for** technical SEO audits, migrations, content inventories, and any workflow where you need “all public URLs the site exposes in sitemaps.”

***

### Support & contact

**Need help?** If something’s unclear, a run fails in an unexpected way, or you’d like a small customization, you can **email [Corentin Robert](mailto:corentin@outreacher.fr)** (`corentin@outreacher.fr`).

***

### What you get

- **One row per URL** in the default dataset, ready to export (JSON, CSV, API).
- **Automatic discovery** from each site’s origin: `robots.txt` **Sitemap:** directives plus common paths (`/sitemap.xml`, WordPress-style paths, etc.).
- **Nested sitemap indexes** followed for you (up to **10** levels deep—fixed in code).
- **Live progress** in **`RUN_LOG`**, plus a **per-site summary** at the end (URL count and sitemap fetch count per input origin).

***

### How it works (short)

1. You add **one start URL per site** (any page on that domain—the actor only uses the **origin**).
2. It resolves **entry sitemap URLs**, then fetches each file (HTTP **200** only).
3. It understands both **`urlset`** (URLs inline) and **`sitemapindex`** (pointers to more sitemaps), then flattens everything into page URLs.

Many sites use a **single** `urlset`; larger sites often ship a root **`sitemapindex`** that fans out to multiple **`urlset`** files—both patterns are supported.

***

### Quick start

1. In the Apify console, open **Site URLs** and paste **one URL per site** (bulk paste or file import works).
2. Start the run. That’s it—timeouts, pacing, and headers are **fixed defaults** (see below).

***

### Input

| Field | What to enter |
|--------|----------------|
| **startUrls** | One URL per website (homepage, blog article, anything on that domain). Same domain twice → one logical “site” in the summary. |

***

### Output (dataset)

| Field | Meaning |
|--------|---------|
| `url` | Page URL from `<loc>` |
| `sourceSitemapUrl` | The **`urlset`** file this row came from |
| `lastmod` | From the sitemap if present, otherwise `null` |
| `discoveredFrom` | `robots` (from robots.txt), `candidate` (default paths), or `nested` (via an index) |
| `fetchedAt` | ISO timestamp when the row was written |

***

### Run log

During the run, **`RUN_LOG`** in the key-value store stays compact—for example:

`12,400 urls · 15 sitemaps`

Failed fetches appear as **`ERR:`** lines (timeout, non-200, or body that isn’t XML)—without dumping raw responses.

When the run finishes, you’ll see **`Per input site (origin):`** with a line per **distinct origin** (URLs collected + sitemaps fetched). The same breakdown is emitted to Apify’s **Log** tab via `log.info`.

***

### Built-in defaults (not shown in the UI)

| Topic | Value |
|--------|--------|
| HTTP timeout | 60 s per request |
| Pause between sitemap requests | 100 ms |
| Extra sitemap paths | None beyond the built-in discovery list |
| `robots.txt` | Read during discovery |
| User-Agent | `SitemapDetector/1.0 (+https://apify.com)` |

***

### Limits & good citizenship

- **Index depth** is capped at **10** nested `sitemapindex` levels (by design).
- Endpoints that return **non-XML** (e.g. JSON “sitemap APIs”) are skipped—you’ll see `not XML` in the log.
- Very large sitemaps mean **longer runs** and **higher memory** use on Apify; that’s expected.
- Use this on sites you’re allowed to query; it only requests **public** sitemap URLs.

***

### Example input

**One site**

```json
{
  "startUrls": [{ "url": "https://example.com/" }]
}
```

**Several sites in one run**

```json
{
  "startUrls": [
    { "url": "https://apify.com/" },
    { "url": "https://vercel.com/docs" }
  ]
}
```

***

### Testing & deploy

**Smoke tests** (parser + live fetches, no full Actor container):

```bash
npm run test:smoke
```

Uses **Apify**, **Doctolib**, and **Vercel** sitemaps as fixtures (the script hits `sitemap.xml` URLs directly; the Actor itself only needs **start URLs**).

**Run the Actor locally**

```bash
apify run --input-file tests/manual-runs/smoke-apify-actor.json
```

More samples: [`tests/manual-runs/`](tests/manual-runs/).

**Publish** — bump [`actor.json`](.actor/actor.json) **`version`** to **`MAJOR.MINOR`** (e.g. `1.7`), not npm-style `1.0.13`, then:

```bash
apify push
```

### Related Actors

These Actors cover the same job or the next step in the workflow. Apify’s automatic recommendations stay inside one category — this list is the rest of the toolkit.

| Actor | Use it when |
|---|---|
| [SW Website Rankings Scraper](https://apify.com/corent1robert/similarweb-scraper) | Rank the website / domain after you have the URL |
| [YouTube Channel Videos · Export All Uploads & Metadata](https://apify.com/corent1robert/youtube-channel-videos-scraper) | YouTube Channel Videos |
| [Apify Creator Scraper · Bulk Profile & Actor Data Export](https://apify.com/corent1robert/apify-users-sitemap-scraper) | Apify Creator Scraper |
| [ATS Careers Detector](https://apify.com/corent1robert/ats-careers-detector) | ATS Careers Detector |
| [Tech Stack Detector · M365 & Google Workspace · By Domain](https://apify.com/corent1robert/collaboration-platform-detector) | Detect M365 / Google Workspace from a domain |
| [Google Maps search — place details & contacts](https://apify.com/corent1robert/google-maps-search-scraper) | Google Maps places, details and contacts |
| [Google Ads Transparency Scraper · Creatives & Impression Ranges](https://apify.com/corent1robert/google-ads-transparency-scraper) | Competitor Google Search / YouTube / Display creatives |
| [French Companies · Search & SIREN Enrich](https://apify.com/corent1robert/recherche-entreprises-scraper) | French companies: search and SIREN enrich |

# Actor input Schema

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

One URL per site (homepage or any page — only the **domain** is used to discover sitemaps). Bulk paste or file import.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://apify.com/"
    }
  ]
}
```

# Actor output Schema

## `dataset` (type: `string`):

One row per URL with source sitemap and metadata

## `urlsView` (type: `string`):

Compact columns: url, sourceSitemapUrl, lastmod, discoveredFrom

## `runLog` (type: `string`):

Live progress: url count · sitemap count

# 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://apify.com/"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("corent1robert/sitemap-detector").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://apify.com/" }] }

# Run the Actor and wait for it to finish
run = client.actor("corent1robert/sitemap-detector").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://apify.com/"
    }
  ]
}' |
apify call corent1robert/sitemap-detector --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,corent1robert/sitemap-detector"
        }
    }
}

```

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/gBqBaKbinap9rEP8r/builds/JZObijid5eXnQM92I/openapi.json
