# Sitemap to AI Corpus: Crawl Any Site for RAG & LLM Training (`turboextract/sitemap-to-ai-corpus`) Actor

Feed in a sitemap.xml URL and get back every page as clean structured JSON. Built for RAG pipelines, LLM fine-tuning, and content intelligence. Pay only for pages with real content.

- **URL**: https://apify.com/turboextract/sitemap-to-ai-corpus.md
- **Developed by:** [Moses Ndambuki](https://apify.com/turboextract) (community)
- **Categories:** AI, 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

$5.00 / 1,000 page successfully processeds

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 to AI Corpus: Crawl Any Site for RAG & LLM Training

**Feed in a sitemap.xml URL. Get back every page as clean, structured JSON for AI training, RAG pipelines, and content intelligence.** Built for ML engineers and AI teams who don't want to hand-compile URL lists.

Paste one sitemap. Get one dataset. Pay only for pages with real content.

***

### Who this is for

- **AI / ML engineers** building training corpora from blogs, documentation sites, and editorial archives
- **RAG developers** populating vector stores with every page on a target domain
- **Dataset curators** harvesting an entire site's published content in a single run
- **Content intelligence teams** monitoring the full output of competitors or partner sites
- **Researchers** assembling source corpora across many domains

If you currently maintain a hand-rolled sitemap parser plus a content scraper, this replaces both.

***

### What you get per page

```json
{
  "url": "https://example.com/blog/rag-explained",
  "title": "How Retrieval Augmented Generation Works",
  "description": "A practical guide to RAG architectures.",
  "author": "Jane Doe",
  "publishedAt": "2026-04-12T08:30:00Z",
  "language": "en",
  "wordCount": 1842,
  "text": "Retrieval augmented generation combines a retriever with a generator...",
  "scrapedAt": "2026-05-02T14:02:11Z"
}
```

The output JSON shape matches **AI Training Dataset Builder** — chain the two actors freely.

***

### How it works

```mermaid
flowchart LR
    A[Input: sitemap.xml URL] --> B[Fetch sitemap]
    B --> C{Sitemap index?}
    C -- yes --> D[Recurse into child sitemaps]
    C -- no --> E[Collect URLs]
    D --> E
    E --> F[Apply include/exclude/lastmod filters]
    F --> G[Headless Chromium crawl]
    G --> H{Word count above threshold?}
    H -- yes --> I[Push item + charge per page]
    H -- no --> J[Skip]
```

Sitemap indexes (sitemap-of-sitemaps) are followed recursively up to 5 levels. Filters apply before crawling so you don't pay for pages you'd discard.

***

### Quick start

#### Run from the Apify Console

1. Click **Try for free**.
2. Paste your sitemap.xml URL.
3. (Optional) Add an include or exclude regex.
4. Click **Start**.
5. Download the dataset as JSON, CSV, or Excel — or stream it into your pipeline.

#### Run from the API

```bash
curl -X POST "https://api.apify.com/v2/acts/Turboextract~sitemap-to-ai-corpus/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "sitemapUrls": [
      { "url": "https://blog.apify.com/sitemap.xml" }
    ],
    "urlPatternInclude": "/blog/",
    "lastmodAfter": "2025-01-01",
    "maxPages": 500,
    "minWordCount": 200
  }'
```

#### Run from Python

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_TOKEN")
run = client.actor("Turboextract/sitemap-to-ai-corpus").call(run_input={
    "sitemapUrls": [{"url": "https://blog.apify.com/sitemap.xml"}],
    "maxPages": 200,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["title"], item["wordCount"])
```

***

### Input fields

| Field | Type | Default | Description |
|---|---|---|---|
| `sitemapUrls` | array | required | One or more sitemap.xml URLs (indexes auto-followed) |
| `urlPatternInclude` | string | — | Regex; only matching URLs are crawled |
| `urlPatternExclude` | string | — | Regex; matching URLs are skipped |
| `lastmodAfter` | string | — | ISO date; skip entries with older lastmod |
| `maxPages` | integer | 50 | Cap per run; raise it (and the run timeout) for full-site crawls |
| `minWordCount` | integer | 50 | Skip thin pages |
| `includeImages` | boolean | false | Attach image URLs from article body |
| `useApifyProxy` | boolean | true | Route through Apify Proxy |

***

### Pricing

**Pay per page processed. No subscriptions.**

| Volume | Price per page | Total |
|---|---|---|
| First 50 pages (free tier) | $0.000 | $0.00 |
| Per page after that | $0.005 | 1,000 pages = $5 |
| 10,000 pages | $0.005 | $50 |

You only pay for pages that return clean content above your word-count threshold. Sitemap fetching, filtered-out URLs, and thin pages cost nothing.

#### How it compares

| Tool | Pricing model | 1,000 pages |
|---|---|---|
| **Sitemap to AI Corpus** | $0.005 per page | **$5** |
| Apify Web Content Crawler | Per result + compute | $7 to $15 |
| Diffbot Article API | $299 per month base | $300+ |
| Custom in-house crawler | Engineer time | $500+ build cost |

***

### Common use cases

- **LLM fine-tuning datasets** from a target site's full archive
- **RAG knowledge bases** populated from `/docs/` or `/blog/` sections
- **Competitive content audits** comparing publishing cadence and depth
- **Site migrations** exporting every page's content as structured JSON
- **Research corpora** assembling sources across many domains

***

### Tips for best results

- Start with `maxPages: 20` to verify extraction quality on your target site
- Use `urlPatternInclude` like `/blog/` or `/docs/` to scope to one section
- Set `minWordCount` higher (200 to 500) for long-form-only datasets
- Use `lastmodAfter` to do incremental refreshes — pair with a weekly scheduler

***

### Pairs well with

- **AI Training Dataset Builder** — same JSON shape; use this actor to discover URLs at scale, then pin specific URL lists in the Builder for surgical updates
- **Reddit Brand Monitor & Lead Finder** — combine site-wide content with social signals
- **Website Lead Extractor** — pair full-site crawl with B2B contact extraction

(Links updated as related actors ship.)

***

### FAQ

**What if a site doesn't have a sitemap?**
Most modern sites do — check `/sitemap.xml`, `/sitemap_index.xml`, or `robots.txt` for the location. If there's no sitemap, use **AI Training Dataset Builder** with a manual URL list instead.

**Does it handle JavaScript-rendered pages?**
Yes. The actor uses headless Chromium via Playwright, so SPAs and JS-heavy sites work the same as static HTML.

**How deep does sitemap recursion go?**
Up to 5 levels of nested sitemap indexes. Most sites don't nest beyond 2.

**Can I crawl multiple sitemaps in one run?**
Yes — pass several URLs in `sitemapUrls`. URLs are deduplicated across sitemaps.

**What about robots.txt?**
The actor reads sitemaps you specify directly. If a site disallows crawling, respect that — the actor doesn't bypass robots.txt directives, but it also doesn't read them. You're responsible for compliance with each site's terms.

**Can I run this on a schedule?**
Yes. Apify's built-in scheduler runs the actor on any cron expression. Combine with `lastmodAfter` for incremental refreshes.

**What if a page fails?**
Failed pages are logged and skipped. You are not charged for failures.

***

### Support

Open an issue on the actor's Apify page or message the maintainer. Bug reports with the failing sitemap or URL get fastest turnaround.

- Source examples and docs: https://github.com/andersonjames38phd-cpu/sitemap-to-ai-corpus
- Community Discord (updates, support, feature requests): https://discord.gg/8SrXSCpvgj

Built and maintained by [Turboextract](https://apify.com/Turboextract) on the Apify platform.

# Actor input Schema

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

One or more sitemap.xml URLs. Sitemap indexes (sitemap-of-sitemaps) are followed automatically.

## `urlPatternInclude` (type: `string`):

Optional regex. Only URLs matching this pattern are crawled. Leave empty to crawl all.

## `urlPatternExclude` (type: `string`):

Optional regex. URLs matching this pattern are skipped.

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

ISO date (e.g. 2025-01-01). Skips sitemap entries with an older lastmod. Entries without lastmod are kept.

## `maxPages` (type: `integer`):

Cap on the number of pages crawled in one run. Raise it for full-site crawls (and raise the run timeout to match).

## `minWordCount` (type: `integer`):

Skip pages below this word count. Filters out thin and empty content.

## `includeImages` (type: `boolean`):

Attach image URLs found inside the article body.

## `useApifyProxy` (type: `boolean`):

Route requests through Apify Proxy to reduce blocking. Recommended.

## Actor input object example

```json
{
  "sitemapUrls": [
    {
      "url": "https://blog.apify.com/sitemap.xml"
    }
  ],
  "maxPages": 20,
  "minWordCount": 50,
  "includeImages": false,
  "useApifyProxy": true
}
```

# Actor output Schema

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

Every crawled page from the sitemap as clean structured JSON.

# 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 = {
    "sitemapUrls": [
        {
            "url": "https://blog.apify.com/sitemap.xml"
        }
    ],
    "maxPages": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("turboextract/sitemap-to-ai-corpus").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 = {
    "sitemapUrls": [{ "url": "https://blog.apify.com/sitemap.xml" }],
    "maxPages": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("turboextract/sitemap-to-ai-corpus").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 '{
  "sitemapUrls": [
    {
      "url": "https://blog.apify.com/sitemap.xml"
    }
  ],
  "maxPages": 20
}' |
apify call turboextract/sitemap-to-ai-corpus --silent --output-dataset

```

## MCP server setup

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

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/bF1SXH7H8mDJAG7XV/builds/1lcdF53HesKvGqCti/openapi.json
