# Fast Website & Sitemap Markdown Crawler for AI/RAG (`tsun_tsun/fast-website-markdown-crawler`) Actor

Crawl docs, blogs, sitemaps, and /llms.txt files over direct HTTP into clean GitHub-Flavored Markdown. Strips site chrome, tracks headings and link graphs, and outputs word and LLM token estimates without Chrome.

- **URL**: https://apify.com/tsun_tsun/fast-website-markdown-crawler.md
- **Developed by:** [tsun tsun](https://apify.com/tsun_tsun) (community)
- **Categories:** AI, Agents, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.05 / 1,000 markdown pages

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

## Fast Website & Sitemap Markdown Crawler for AI/RAG

Turn documentation portals, technical blogs, XML sitemaps, and `/llms.txt` endpoints into clean GitHub-Flavored Markdown over direct HTTP with no headless browser. For every crawled page, the crawler pulls `robots.txt` and nested `/sitemap.xml` trees (up to 20 child sitemaps per origin), locates the main document landmark (`main`, `article`, `[role="main"]`, `.markdown-body`, `.docs-content`, or `body`), strips navbars, sidebars, footers, breadcrumbs, and cookie banners, and emits Markdown with word counts, token estimates, heading outlines, and deduplicated link arrays.

### Use cases

- Index documentation sites built on Docusaurus, Mintlify, GitBook, ReadTheDocs, or Next.js SSR into Qdrant, Pinecone, or `pgvector` with optional `maxMarkdownChars` caps per page.
- Pull pre-rendered `/llms-full.txt` or `/llms.txt` files on developer portals in one HTTP round-trip via `preferLlmsTxt: true`.
- Give Claude Code or Cursor on-demand access to scoped product docs via Apify MCP without spinning up Chrome containers.
- Audit site structure across multiple domains by exporting `canonicalUrl`, `headings`, `internalLinks`, `externalLinks`, and `wordCount`.

### Crawl scope & `/llms.txt` fast path

Each Start URL sets an origin and path scope automatically, and adapts when a depth-0 Start URL permanently redirects to another non-root path on the same host (for instance `/platform/actors` to `/actors`). Scope narrows further with `includePathPrefix`, segment-aware `includePathPatterns`, and `excludePathPatterns` (a leading `/` enforces whole-segment matching so `/cart` blocks `/cart/items` without blocking `/cartoon`).

Enabling `preferLlmsTxt` probes `/llms-full.txt` and `/llms.txt` on each origin before any HTML crawl begins. Soft-200 HTML fallback pages are rejected automatically, converging origins (such as apex and `www`) deduplicate prior to billing, and Markdown links parse through a linear O(N) scanner that handles balanced parentheses like `Python_(programming_language)`. Headings inside `<article><header><h1>`, nested lists, GFM tables, blockquotes, and language-tagged code fences remain intact during HTML cleanup.

### Inputs & crawl filters

| Parameter | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `startUrls` | `string[]` | *(required)* | One or more public HTTP(S) root URLs across one or multiple domains. |
| `useSitemap` | `boolean` | `true` | Seed scoped internal URLs from `robots.txt` and `/sitemap.xml`. |
| `preferLlmsTxt` | `boolean` | `false` | Check `/llms-full.txt` and `/llms.txt` on each origin before HTML crawling. |
| `includePathPrefix` | `string` | `""` | Exact path-segment prefix (e.g. `"/actors"` skips `"/actors-v2"`). |
| `includePathPatterns` | `string[]` | `[]` | Allowlist of path segments (leading `/`) or URL substrings. |
| `excludePathPatterns` | `string[]` | *(5 auth/cart paths)* | Path segments or substrings to skip. |
| `maxPages` | `integer` | `25` | Max valid Markdown pages pushed (`1-2000`). |
| `maxDepth` | `integer` | `2` | Max internal link hops from Start URLs (`0-5`). |
| `maxMarkdownChars` | `integer` | `0` | Optional character cap per page at clean boundaries (`0-200000`; `0` = unlimited). |
| `concurrency` | `integer` | `5` | Parallel HTTP fetches (`1-15`). |
| `includeLinks` | `boolean` | `true` | Include deduplicated `internalLinks` and `externalLinks` arrays. |

Default `excludePathPatterns` skips `["/login", "/signup", "/cart", "/checkout", "/wp-admin"]`.

#### Example input

```json
{
  "startUrls": ["https://docs.apify.com/actors"],
  "useSitemap": true,
  "preferLlmsTxt": false,
  "includePathPrefix": "/actors",
  "includePathPatterns": [],
  "maxPages": 25,
  "maxDepth": 2,
  "maxMarkdownChars": 0,
  "concurrency": 5,
  "includeLinks": true
}
```

### Sample Markdown record

```json
{
  "url": "https://docs.apify.com/actors",
  "canonicalUrl": "https://docs.apify.com/actors",
  "httpStatus": 200,
  "depth": 0,
  "title": "Actors | Apify Documentation",
  "metaDescription": "Actors are serverless cloud programs for web scraping and web automation.",
  "language": "en",
  "headings": ["Actors", "Development", "Running Actors", "Publishing"],
  "wordCount": 684,
  "estimatedTokens": 910,
  "markdown": "# Actors\n\nActors are serverless cloud programs for web scraping and web automation...",
  "internalLinks": ["https://docs.apify.com/actors/running"],
  "externalLinks": ["https://github.com/apify/apify-sdk-js"],
  "scrapedAt": "2026-11-24T17:42:19.412Z"
}
```

#### Field definitions

| Field | Type | Description |
| :--- | :--- | :--- |
| `url` | `string` | Normalized final URL after redirects and tracking-param stripping. |
| `canonicalUrl` | `string \| null` | Resolved `<link rel="canonical">` URL if present. |
| `httpStatus` | `number` | HTTP status code returned by the page. |
| `depth` | `number` | Link hop depth (`0` for Start URLs, sitemaps, and `llms.txt` files). |
| `title` | `string \| null` | Document `<title>`, fallback `<h1>`, or `llms.txt` heading. |
| `metaDescription` | `string \| null` | Meta description, `og:description`, or `llms.txt` lead quote. |
| `language` | `string \| null` | HTML `lang` attribute. |
| `headings` | `string[]` | Ordered `h1-h6` headings (up to 50). |
| `wordCount` | `number` | Word count of the delivered `markdown`. |
| `estimatedTokens` | `number` | Approximate LLM tokens (`Math.ceil(wordCount * 1.33)`). |
| `markdown` | `string` | Clean GitHub-Flavored Markdown body. |
| `internalLinks` | `string[]` | Deduplicated same-host links (`[]` when `includeLinks: false`). |
| `externalLinks` | `string[]` | Deduplicated external links (`[]` when `includeLinks: false`). |
| `scrapedAt` | `string` | ISO 8601 UTC extraction timestamp. |

### Pay-Per-Event pricing

Pay-Per-Event billing on `page-crawled` with **$0 actor-start fee** and **$0 proxy fees**. Dead links, soft-404s, binaries, thin hub pages (`< 10` words), and canonical duplicates are never charged.

| Event (Apify Store Label) | Free / 1k | Bronze (-10%) | Silver (-20%) | Gold+ (-30%) |
| :--- | :--- | :--- | :--- | :--- |
| Markdown page | `$1.50` | `$1.35` | `$1.20` | `$1.05` |

`Gold+` includes Gold, Platinum, and Diamond plans (all `-30%`, or `$0.00105` per page). Apify's **$5 monthly free credit** covers **3,333 Markdown pages/month** on the Free plan.

### MCP, SDK & HTTP usage

#### Claude Code (MCP)

```bash
claude mcp add --transport http apify-markdown \
  "https://mcp.apify.com/?tools=tsun_tsun/fast-website-markdown-crawler" \
  --header "Authorization: Bearer $APIFY_TOKEN"
```

#### Claude Desktop, Cursor & Windsurf (MCP)

```json
{
  "mcpServers": {
    "apify-markdown": {
      "url": "https://mcp.apify.com/?tools=tsun_tsun/fast-website-markdown-crawler",
      "headers": {
        "Authorization": "Bearer YOUR_APIFY_TOKEN"
      }
    }
  }
}
```

#### JavaScript / TypeScript (`apify-client`)

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('tsun_tsun/fast-website-markdown-crawler').call({
  startUrls: ['https://docs.apify.com/actors'],
  includePathPrefix: '/actors',
  maxPages: 25,
  maxMarkdownChars: 16000,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items[0].title, items[0].estimatedTokens);
```

#### Python (`apify-client`)

```python
import os
from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("tsun_tsun/fast-website-markdown-crawler").call(
    run_input={
        "startUrls": ["https://docs.apify.com/actors"],
        "includePathPrefix": "/actors",
        "maxPages": 25,
        "preferLlmsTxt": False,
    }
)
items = client.dataset(run["defaultDatasetId"]).list_items().items
print(len(items), items[0]["url"])
```

#### cURL

```bash
curl -X POST "https://api.apify.com/v2/acts/tsun_tsun~fast-website-markdown-crawler/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "startUrls": ["https://docs.apify.com/actors"],
    "includePathPrefix": "/actors",
    "maxPages": 10
  }'
```

### Benchmarks & constraints

Measured on Apify Cloud at default 256 MB memory, a 3-page crawl completed in `2.15 s` at `52.0 MB` peak RAM (`128 MB` minimum memory). Requests enforce a 15-second page timeout, 5 MB HTML cap, 10 MB sitemap cap, UTF-16 surrogate-safe `maxMarkdownChars` boundary truncation, `Retry-After` backoff on `429`/`5xx`, DNS-level SSRF protection across inputs, redirects, and sitemaps (blocking private IPv4/IPv6, metadata hosts, NAT64/Teredo/6to4, and `.local`/`.internal`), and clean `OUTPUT` flushing on abort.

Skip this crawler if your target is a pure client-side SPA serving an empty `<div id="root"></div>` without server rendering (use a Playwright or Puppeteer crawler instead), sits behind Cloudflare Turnstile, logins, or residential proxy walls, or requires binary extraction from PDF, DOCX, or image assets.

### Frequently asked questions

#### What happens when `preferLlmsTxt: true` is set on a site without `/llms-full.txt`?

The crawler tries `/llms-full.txt` first and `/llms.txt` second, discarding any HTML fallback page returned with status 200. If `/llms-full.txt` is valid Markdown/text, it emits that single document and skips HTML crawling for that origin. If only `/llms.txt` is valid, it emits the index and queues its scoped internal links. If neither exists, normal sitemap + HTML crawling runs unchanged.

#### Why did a start page with fewer than 10 words not appear in the dataset?

Thin navigation hub pages (`wordCount < 10`) are still crawled so their `internalLinks` seed depth-1 pages, but they are excluded from `Actor.pushData` so you are not billed for empty directory pages.

#### How does `maxMarkdownChars` avoid corrupting Markdown or emoji characters?

Truncation cuts cleanly at a paragraph (`\n\n`), line (`\n`), or word boundary within the limit, strips any lone trailing UTF-16 high surrogate so astral-plane characters never split mid-pair, and recalculates `wordCount` and `estimatedTokens` from the truncated text.

#### Does this crawler respect canonical duplicates across redirects?

Yes. Tracking query parameters (`utm_*`, `fbclid`, `gclid`) are stripped, `<base href>` and `<link rel="canonical">` are resolved, and pages matching an already-pushed final URL or canonical URL are dropped at `$0`.

### Related Actors

Companion lightweight API Actors and free workflow templates in the [Apify Automation Toolkit](https://pie527645-cloud.github.io/apify-automation-toolkit/):

| Actor | Best paired for |
| :--- | :--- |
| [Google News & Universal RSS/Atom Feed Scraper](https://apify.com/tsun_tsun/google-news-rss-intelligence) | Discover fresh news URLs and feed articles to crawl into full Markdown. |
| [Substack Newsletter & Archive Scraper (Markdown)](https://apify.com/tsun_tsun/substack-intelligence-scraper) | Extract Substack archives, engagement counts, and clean Markdown posts. |
| [Wikipedia Knowledge & RAG Markdown Scraper (API)](https://apify.com/tsun_tsun/wikipedia-rag-knowledge-scraper) | Pull clean Wikipedia Markdown, infobox JSON, and Wikidata Q-IDs via Wikimedia APIs. |
| [Apple Podcasts & RSS Scraper (Host Emails & Shows)](https://apify.com/tsun_tsun/apple-podcasts-rss-scraper) | Extract podcast host emails, show profiles, audio links, and episode show notes. |
| [Apple App Store & Reviews Scraper (iOS Apps & Ratings)](https://apify.com/tsun_tsun/app-store-reviews-scraper) | Monitor iOS app metadata and filtered customer reviews across storefronts. |
| [Website Contact, Email MX/DMARC & Tech Stack Enricher](https://apify.com/tsun_tsun/website-lead-tech-enricher) | Enrich crawled domains with contact info, DNS/MX/DMARC records, and detected tech stacks. |

# Changelog

This Actor's version history is a separate document: https://apify.com/tsun_tsun/fast-website-markdown-crawler/changelog.md

# Actor input Schema

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

One or more public http(s) documentation, blog, or website URLs to crawl (e.g. https://docs.apify.com/actors). Supports multi-domain and multi-path roots.

## `useSitemap` (type: `boolean`):

Read robots.txt Sitemap directives and /sitemap.xml (including nested sitemapindex files up to 20 child sitemaps) per origin to seed scoped internal URLs.

## `preferLlmsTxt` (type: `boolean`):

When enabled, checks /llms-full.txt and /llms.txt on each start origin before HTML crawling. If /llms-full.txt is served as valid plain text/Markdown, emits it directly and skips HTML crawling for that origin; if /llms.txt is served, emits it and seeds its scoped links.

## `includePathPrefix` (type: `string`):

Restrict crawled URLs to exact path segment prefixes (e.g. '/actors' matches '/actors/running' but not '/actors-v2'). Leave blank to auto-scope per Start URL.

## `includePathPatterns` (type: `array`):

Optional allowlist of path segments (leading '/' matches whole path segments, e.g. '/guides' matches '/guides/rag' without matching '/guides-old') or URL substrings. When non-empty, only matching internal URLs are crawled and emitted.

## `excludePathPatterns` (type: `array`):

Skip internal URLs matching these path segments (leading '/' matches whole path segments, so '/cart' skips '/cart/items' without blocking '/cartoon') or substrings.

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

Maximum number of valid HTTP 2xx pages with real content to convert to Markdown and push to the dataset.

## `maxDepth` (type: `integer`):

Maximum internal link hops from Start URLs (0 crawls only Start URLs and sitemap seeds).

## `maxMarkdownChars` (type: `integer`):

Optional character cap per page applied at a paragraph, line, or word boundary for token-budgeted RAG pipelines. Set 0 to return full page Markdown.

## `concurrency` (type: `integer`):

Number of concurrent HTTP page fetches executed in parallel (1 to 15).

## `includeLinks` (type: `boolean`):

Include deduplicated, normalized internalLinks and externalLinks arrays on every dataset record.

## Actor input object example

```json
{
  "startUrls": [
    "https://docs.apify.com/actors"
  ],
  "useSitemap": true,
  "preferLlmsTxt": false,
  "includePathPrefix": "/actors",
  "includePathPatterns": [
    "/guides"
  ],
  "excludePathPatterns": [
    "/login",
    "/signup",
    "/cart"
  ],
  "maxPages": 25,
  "maxDepth": 2,
  "maxMarkdownChars": 16000,
  "concurrency": 5,
  "includeLinks": true
}
```

# Actor output Schema

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

JSON summary with crawled hosts, page counts, total word/token counts, llms.txt sources used, and budget status.

## `pages` (type: `string`):

Extracted page records containing clean GitHub-Flavored Markdown, headings, word/token counts, and internal/external links.

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

// Run the Actor and wait for it to finish
const run = await client.actor("tsun_tsun/fast-website-markdown-crawler").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://docs.apify.com/actors"] }

# Run the Actor and wait for it to finish
run = client.actor("tsun_tsun/fast-website-markdown-crawler").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://docs.apify.com/actors"
  ]
}' |
apify call tsun_tsun/fast-website-markdown-crawler --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,tsun_tsun/fast-website-markdown-crawler"
        }
    }
}
```

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/TYW2jHA6uRluH9XpU/builds/yHC7dxO6KSSctOGhC/openapi.json
