# Sitemap Content Extractor — Website to Clean Markdown (`celebrated-quadraphonic/sitemap-content-extractor`) Actor

Turn any website's sitemap into clean, LLM-ready Markdown. Auto-discovers sitemaps via robots.txt, extracts article text, tables, headings, links and images while stripping navigation, ads and cookie banners. Filter pages by lastmod date.

- **URL**: https://apify.com/celebrated-quadraphonic/sitemap-content-extractor.md
- **Developed by:** [XiaoZhi DataTools](https://apify.com/celebrated-quadraphonic) (community)
- **Categories:** Developer tools, AI, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 page extracteds

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 Content Extractor — Website to Clean Markdown

Turn any website's sitemap into clean, LLM-ready Markdown. Give it a domain
(or a sitemap URL) and get back the full text content of every page —
no browser, no login, no residential proxies, pure HTTP.

### What it does

1. **Discovers sitemaps** — reads `robots.txt` `Sitemap:` directives and
   probes common locations (`/sitemap.xml`, `/sitemap_index.xml`, …).
   You can also pass sitemap URLs directly.
2. **Expands sitemap indexes** — recursively follows nested sitemaps
   (multi-level indexes, gzipped `.xml.gz`, plain-text sitemaps).
3. **Fetches every page concurrently** — honors `robots.txt` Disallow rules,
   follows redirects, skips non-HTML content, retries transient failures.
4. **Extracts clean content** — strips navigation, headers, footers, sidebars,
   scripts and cookie banners; keeps the main article content as Markdown
   with headings, links (absolute URLs), images and **tables rendered as
   Markdown pipe tables** (`| a | b |`). Headings are detected even when
   nested inside link cards or custom web components (common on news and
   React/SSR sites).

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `startUrls` | string\[] | — | Domains or sitemap URLs, e.g. `apify.com`, `https://example.com/sitemap.xml` |
| `maxPages` | integer | 100 | Max pages to fetch and extract (up to 50,000) |
| `maxSitemapDepth` | integer | 3 | Nested sitemap-index levels to expand |
| `urlPatternInclude` | string\[] | — | Only keep URLs matching these regexes (one per line), e.g. `/docs/` |
| `urlPatternExclude` | string\[] | — | Skip URLs matching these regexes, e.g. `/tag/` |
| `minLastmod` | string | — | Only keep URLs with sitemap `lastmod` on/after this date (`YYYY-MM-DD`); URLs without `lastmod` are kept |
| `maxLastmod` | string | — | Only keep URLs with sitemap `lastmod` on/before this date (`YYYY-MM-DD`); URLs without `lastmod` are kept |
| `outputFormat` | markdown/text/html | markdown | `markdown` (best for LLMs), `text`, or cleaned `html` |
| `includeMetadata` | boolean | true | Title, meta description, language, headings, outbound links, image counts |
| `maxContentChars` | integer | 0 | Truncate content per page (0 = no limit) |
| `limitToStartDomain` | boolean | true | Only fetch URLs on the start domain |
| `respectRobotsTxt` | boolean | true | Honor `robots.txt` Disallow rules |
| `requestConcurrency` | integer | 10 | Parallel page fetches (1–30) |
| `proxyConfiguration` | proxy | off | Optional; not needed for typical runs |

### Output

One dataset item per page:

```json
{
  "url": "https://apify.com/about",
  "finalUrl": "https://apify.com/about",
  "statusCode": 200,
  "sitemapUrl": "https://apify.com/sitemap/pages.xml",
  "lastmod": "2026-09-20",
  "changefreq": null,
  "priority": null,
  "contentFormat": "markdown",
  "content": "# About Apify\n\nWe're building the world's largest platform...",
  "contentChars": 4821,
  "wordCount": 548,
  "title": "About Apify",
  "metaDescription": "...",
  "language": "en",
  "headings": [{ "level": 1, "text": "About Apify" }],
  "links": ["https://docs.apify.com/legal"],
  "linksCount": 31,
  "imagesCount": 4,
  "fetchedAt": "2026-09-28T10:00:00+00:00"
}
```

### Use cases

- **RAG / LLM ingestion** — dump an entire docs site or blog into clean
  Markdown for embeddings or fine-tuning datasets.
- **Site content audits** — inventory every page with titles, descriptions,
  word counts and lastmod dates.
- **Competitor research** — extract a competitor's full public content
  footprint from their sitemap.
- **SEO analysis** — pair sitemap metadata (lastmod, priority) with actual
  on-page headings and word counts.
- **Change monitoring** — re-run on a schedule and diff `content` per URL.

### Cost & performance

- Pure HTTP (no headless browser), so a run costs a fraction of
  browser-based crawlers — roughly **$0.001–0.003 per 1,000 pages** in
  Apify compute.
- \~10 pages/second at default concurrency; 30 pages fetched and extracted
  in ~2 seconds in testing.
- No residential proxies required: sitemaps and public pages are served to
  plain HTTP clients.

### Limitations

- Only pages listed in sitemaps are fetched (orphan pages not in any
  sitemap are missed) — this is by design: sitemap-driven, not link-crawling.
- JavaScript-rendered content is not executed; pages that require JS to
  render body text will yield thin results.
- `robots.txt` Disallow rules are honored by default (can be disabled).
- Very large pages are truncated at 5 MB download size.
- Non-HTML responses (PDFs, images, feeds) are skipped.

### Changelog

- **0.5** — Fixed gzipped sitemaps (`.xml.gz`) served with
  `application/gzip` / `application/octet-stream` content types being
  silently skipped; added retries with backoff for transient HTTP
  statuses (429, 500, 502, 503, 504) instead of failing immediately.
- **0.4** — Previous release.

# Actor input Schema

## `includeMetadata` (type: `boolean`):

Include title, meta description, language, headings, outbound links and image counts.

## `limitToStartDomain` (type: `boolean`):

Only fetch URLs on the same domain as the start URL.

## `maxContentChars` (type: `integer`):

Truncate extracted content per page to this many characters. 0 = no truncation.

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

Maximum number of pages to fetch and extract.

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

How many nested sitemap-index levels to expand.

## `outputFormat` (type: `string`):

Content format: clean Markdown (best for LLMs), plain text, or cleaned HTML.

## `proxyConfiguration` (type: `object`):

Optional. Sitemaps and pages are fetched over plain HTTP; proxies are not needed for typical runs.

## `requestConcurrency` (type: `integer`):

How many pages to fetch in parallel.

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

Honor robots.txt Disallow rules when fetching page content.

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

Domains or sitemap URLs, one per line. Examples: apify.com, https://example.com/sitemap.xml

## `urlPatternInclude` (type: `array`):

Only keep URLs matching at least one of these regular expressions, one per line. Example: /docs/

## `urlPatternExclude` (type: `array`):

Skip URLs matching any of these regular expressions, one per line. Example: /blog/draft

## `minLastmod` (type: `string`):

Only keep URLs whose sitemap lastmod is on/after this date (YYYY-MM-DD). URLs without lastmod are kept.

## `maxLastmod` (type: `string`):

Only keep URLs whose sitemap lastmod is on/before this date (YYYY-MM-DD). URLs without lastmod are kept.

## Actor input object example

```json
{
  "includeMetadata": true,
  "limitToStartDomain": true,
  "maxContentChars": 0,
  "maxPages": 100,
  "maxSitemapDepth": 3,
  "outputFormat": "markdown",
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "requestConcurrency": 10,
  "respectRobotsTxt": true,
  "startUrls": [
    "apify.com"
  ],
  "minLastmod": "",
  "maxLastmod": ""
}
```

# Actor output Schema

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

No description

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

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

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

```

## MCP server setup

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