# Website Content Crawler – RAG Chunks for Vector DBs (`leadsbrary/website-rag-chunk-feed`) Actor

Website content crawler for RAG: turn any site into token-counted, heading-aware chunks with chunk ID, overlap, heading path, offsets, content hash and source URL. Export JSON, CSV or Excel. From $0.80 per 1,000 chunks.

- **URL**: https://apify.com/leadsbrary/website-rag-chunk-feed.md
- **Developed by:** [Alexandre Manguis](https://apify.com/leadsbrary) (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

from $0.80 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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

## Website Content Crawler RAG Chunks for Vector DBs

This website content crawler RAG chunks Actor outputs embedding-ready chunks, not raw pages: give it one or more start URLs and it crawls the site, extracts the main content, and splits it with a token-aware, heading-aware splitter into one dataset row per chunk — each with a stable `chunkId`, `tokenCount`, `overlapTokensWithPrevious`, `headingPath`, character offsets, a `contentHash` and the exact source URL. Push the dataset straight into Pinecone, Qdrant, pgvector or Chroma, or feed an MCP/agent retrieval tool — no manual chunking step.

### Who it's for

AI/RAG engineers, AI agencies and indie builders who ingest documentation sites, help centers, changelogs or blogs into a vector database or an agent/MCP tool.

Use cases:

- Crawl a documentation site and embed the chunks directly, using `chunkId` as the upsert key.
- Re-crawl the same site on a schedule and use `contentHash` + `chunkId` to re-embed only the chunks whose text actually changed.
- Feed an MCP server or agent retrieval tool with pre-chunked, source-attributed content — every chunk keeps its URL and heading path for citations.
- Build an evaluation or fine-tuning corpus from a public knowledge base with token counts already measured per chunk.

### What it does not do

- No JavaScript rendering — plain HTTP + HTML parsing only. Pages that render content client-side yield a `skipped` row (`skipReason: "empty_content"`); use a browser-based crawler for those sites.
- No login, paywall or access-control bypass, and no CAPTCHA solving.
- No embeddings are generated and no third-party LLM/embedding API is called — only chunking and tokenization.
- `robots.txt` is honoured by default (`respectRobotsTxt: true`).

### Features

- One dataset row per **chunk**, not per page, with a stable `chunkId` derived from the URL and the chunk's content hash — safe to use as a vector-DB upsert key.
- Token-aware chunking against the real tokenizer (`cl100k_base` or `o200k_base`), not an estimate — `tokenCount` is measured.
- Heading-aware splitting (`heading-recursive`) keeps each chunk under its markdown heading breadcrumb (`headingPath`); `recursive` and `page` (one chunk per page) are also available.
- `overlapTokensWithPrevious` and character offsets (`startCharOffset`/`endCharOffset`) giving the offsets of the chunk's new (non-overlapping) content within the page's cleaned main-content markdown. They are useful for ordering and de-duplication, not for HTML positions, and the overlap prefix is not included.
- `contentHash` lets a re-crawl skip re-embedding chunks whose text hasn't changed.
- Billing is **per delivered chunk row**, never for pages that produce no chunk (see Pricing).
- Pages that fail (including HTTP 404/5xx error pages) or produce no usable content become a diagnostic `status: "skipped"` row (`skipReason`: `robots_disallowed`, `http_error`, `non_html`, `empty_content`, `blocked` or `below_min_chunk_chars`) and are never billed.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `startUrls` | array (required) | — | Pages or sections to crawl, as `{url}` objects. |
| `maxCrawlDepth` | integer | `1` | Link hops to follow from each start URL. `0` = only the start URLs. |
| `maxCrawlPages` | integer | `50` | Hard cap on pages fetched (including pages that produce no chunk). |
| `maxResults` | integer | `5000` | Hard cap on chunk rows pushed to the dataset. |
| `sameDomainOnly` | boolean | `true` | Follow links only on the same hostname as the start URL. |
| `includeUrlGlobs` | array | — | URL glob patterns that must match to be crawled, e.g. `https://docs.example.com/guide/**`. |
| `excludeUrlGlobs` | array | — | URL glob patterns to exclude (changelogs, archives, locale duplicates). |
| `respectRobotsTxt` | boolean | `true` | Honour `robots.txt` disallow rules (crawl-delay is not applied; control pacing with `maxConcurrency`). |
| `chunkStrategy` | enum | `heading-recursive` | `heading-recursive` (split on headings, then recursively on paragraphs/sentences), `recursive` (ignore headings), or `page` (one chunk per page, no splitting). |
| `chunkSize` | integer | `512` | Target chunk size, in tokens of the selected tokenizer. |
| `chunkOverlap` | integer | `64` | Tokens of the previous chunk repeated at the start of the next one. Must be smaller than `chunkSize`. |
| `minChunkChars` | integer | `120` | Chunks shorter than this (nav leftovers, empty sections) are dropped. |
| `tokenizer` | enum | `cl100k_base` | `cl100k_base` (matches `text-embedding-3-*`/`ada-002`) or `o200k_base`. |
| `outputFormat` | enum | `markdown` | `markdown` (keeps headings, lists, code fences) or `text`. |
| `includePageMetadata` | boolean | `true` | Include per-page metadata (description, author, publishedAt, modifiedAt) on every chunk row. |
| `proxyConfiguration` | object | off | Optional — only needed if the target site rate-limits datacenter traffic. |

### Output

Each dataset row is one chunk (or one diagnostic `skipped` row for a page that produced none). Example row from a production run on `docs.python.org` (`test/production-sample.json`; `text` and `description` abridged here):

```json
{
  "chunkId": "doc_9d6548fc_0000",
  "url": "https://docs.python.org/3/tutorial/introduction.html",
  "canonicalUrl": "https://docs.python.org/3/tutorial/introduction.html",
  "pageTitle": "3. An Informal Introduction to Python",
  "headingPath": [],
  "chunkIndex": 0,
  "totalChunksForPage": 13,
  "text": "In the following examples, input and output are distinguished by the presence or absence of prompts (>>> and …): to repeat the example, you must type everything after the prompt...",
  "tokenCount": 399,
  "charCount": 1816,
  "overlapTokensWithPrevious": 0,
  "startCharOffset": 0,
  "endCharOffset": 1967,
  "contentHash": "b9176f2f827b1101",
  "language": "en",
  "pageMetadata": {
    "description": "In the following examples, input and output are distinguished by the presence or absence of prompts...",
    "author": null,
    "publishedAt": null,
    "modifiedAt": null
  },
  "depth": 0,
  "httpStatus": 200,
  "crawledAt": "2026-10-03T10:28:22.952Z",
  "chunkStrategy": "heading-recursive",
  "tokenizer": "cl100k_base",
  "status": "ok",
  "skipReason": null
}
```

A page that renders its content client-side (no browser rendering, by design — see "What it does not do") instead produces a row like this, from a real production run against `https://app.gitbook.com/`:

```json
{
  "url": "https://app.gitbook.com/",
  "status": "skipped",
  "skipReason": "empty_content",
  "depth": 0,
  "httpStatus": 200,
  "crawledAt": "2026-10-03T10:33:06.050Z"
}
```

#### Output fields & fill rates

Measured on a 300-row production crawl (run `p2g0zPUyHJ7odzZxW`, 2026-10-03, three documentation sites, source: `TEST_REPORT.json` → `production.medium.fill_rates`):

| Field | Fill rate | Notes |
|---|---|---|
| `chunkId`, `url`, `canonicalUrl`, `chunkIndex`, `totalChunksForPage`, `text`, `tokenCount`, `charCount`, `overlapTokensWithPrevious`, `startCharOffset`, `endCharOffset`, `contentHash`, `language`, `pageMetadata`, `pageTitle`, `depth`, `httpStatus`, `crawledAt`, `chunkStrategy`, `tokenizer`, `status` | 100% | Always present on `ok` rows |
| `headingPath` | 18.0% | Empty array when no markdown heading sits above the chunk; this crawl had many such chunks (0% in `page` mode, 92.6% on the single Python tutorial page) |
| `skipReason` | 0% on this run | Only populated on `skipped` rows; this crawl produced none |

#### Examples of each mode (real production runs)

| Mode / input | Result |
|---|---|
| `heading-recursive`, `chunkSize: 64`, `chunkOverlap: 0` on one Python tutorial page | Run `YMxROYMhv6SCb9sus`: 81 chunk rows for that page (small chunks, so many rows) |
| `chunkStrategy: "page"` on the same page | Run `99VDMdsXGFKObirDs`: 1 row, 5,063 tokens, `headingPath` empty |
| Client-side-rendered page (`app.gitbook.com`) | Run `XYXPLttPDnUAtEJR6`: 1 `skipped` row, `empty_content` |
| Three start URLs: a robots.txt-disallowed page, a missing page (404) and a PDF | Run `8yV7eaBUGhj86kLyR` (current build) SUCCEEDED with 3 rows, no error rows and `httpStatus` filled on 2 of 3 (the robots-disallowed page is never fetched, so its `httpStatus` is `null`). The first row is `skipped` / `robots_disallowed`. Pages answering HTTP 4xx/5xx become `skipped` rows with `skipReason: "http_error"` (`"blocked"` for 403/429), are never chunked or billed, and their links are not followed — covered by a unit test (`httpErrorSkipReason`). The per-row `skipReason` of the 404 and PDF rows is not recorded in the test report; an earlier run (`WBGWl2ojFr0melpqt`, older build) billed a 404 page before this fix |
| Missing `startUrls` | Rejected before the run starts with an Apify "invalid input" error (`Field input.startUrls is required`). Malformed URLs inside `startUrls` are rejected the same way by Apify's input validation |

### How to use

Run via the Apify API (replace `<TOKEN>`):

**curl**

```bash
curl "https://api.apify.com/v2/acts/YOUR_USERNAME~website-rag-chunk-feed/run-sync-get-dataset-items?token=<TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
    "startUrls": [{ "url": "https://docs.apify.com/academy" }],
    "maxCrawlDepth": 1,
    "maxCrawlPages": 50,
    "chunkStrategy": "heading-recursive",
    "chunkSize": 512,
    "chunkOverlap": 64
  }'
```

**JavaScript**

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

const client = new ApifyClient({ token: '<TOKEN>' });

const run = await client.actor('YOUR_USERNAME/website-rag-chunk-feed').call({
  startUrls: [{ url: 'https://docs.apify.com/academy' }],
  maxCrawlDepth: 1,
  maxCrawlPages: 50,
  chunkStrategy: 'heading-recursive',
  chunkSize: 512,
  chunkOverlap: 64,
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

**Python**

```python
from apify_client import ApifyClient

client = ApifyClient("<TOKEN>")

run = client.actor("YOUR_USERNAME/website-rag-chunk-feed").call(run_input={
    "startUrls": [{"url": "https://docs.apify.com/academy"}],
    "maxCrawlDepth": 1,
    "maxCrawlPages": 50,
    "chunkStrategy": "heading-recursive",
    "chunkSize": 512,
    "chunkOverlap": 64,
    "includePageMetadata": True,
})

items = client.dataset(run["defaultDatasetId"]).list_items().items
print(items)
```

#### Loading chunks into a vector DB

Use `chunkId` as the upsert key and skip re-embedding when `contentHash` hasn't changed:

```javascript
for (const chunk of items) {
  const existing = await myVectorStore.get(chunk.chunkId);
  if (existing && existing.contentHash === chunk.contentHash) continue; // unchanged, skip
  const embedding = await embed(chunk.text);
  await myVectorStore.upsert(chunk.chunkId, embedding, {
    text: chunk.text,
    url: chunk.url,
    headingPath: chunk.headingPath,
    contentHash: chunk.contentHash,
  });
}
```

### Pricing

Pay-per-event: **one `page-chunked` charge per delivered chunk row** (every `ok` row is billed), never for `skipped` pages/rows.

| Tier | Price per 1,000 chunk rows |
|---|---|
| FREE | $1.20 |
| BRONZE | $1.04 |
| SILVER | $0.92 |
| GOLD / PLATINUM / DIAMOND | $0.80 |

Tune `chunkSize`/`chunkOverlap`/`chunkStrategy` to control how many chunk rows (and therefore how much you're billed) a page produces: e.g. `chunkStrategy: "page"` yields exactly 1 row per page, while a smaller `chunkSize` yields more, smaller rows for the same content (one Python tutorial page gave 81 rows at `chunkSize: 64`, 1 row in `page` mode).

### Troubleshooting

- **A page yields a `skipped` row with `skipReason: "empty_content"`** — the page renders its content with JavaScript; this Actor only fetches HTML over plain HTTP. Use a browser-based crawler for that site.
- **Link text shows escapes such as `[\>>>]`** — the HTML-to-markdown conversion keeps markdown escapes inside link text; they are harmless for embedding but visible in raw `text`.
- **`skipReason: "robots_disallowed"`** — the page is disallowed by the site's `robots.txt`. Set `respectRobotsTxt: false` only for sites you own.
- **`skipReason: "blocked"` or many `http_error` rows** — the target is rate-limiting Apify's datacenter IPs. Enable `proxyConfiguration` (`DATACENTER` first, then `RESIDENTIAL` if still blocked).
- **`headingPath` is often empty** — the page has no markdown headings above that chunk (confirmed on the measured run above: 18.0% fill rate on a mixed three-site crawl, not 100%). This is expected on pages without a heading structure, not a bug.
- **The run hits `maxCrawlPages` before finishing the site** — raise `maxCrawlPages`/`maxCrawlDepth`, or narrow the crawl with `includeUrlGlobs`/`excludeUrlGlobs` to avoid wasting the cap on irrelevant pages.

### FAQ

**Does this generate embeddings?**
No. It outputs chunked, tokenized text ready to pass to the embedding model of your choice; it never calls an embedding or LLM API itself.

**Can it crawl sites that need a login?**
No. It only fetches publicly reachable pages; it never submits credentials, reuses cookies/tokens, or bypasses a paywall or access control.

**Does it respect `robots.txt`?**
Yes, by default (`respectRobotsTxt: true`), for disallow rules (crawl-delay is not applied). Turn it off only for sites you own or are explicitly allowed to crawl without restriction.

**What if the crawled pages contain personal data (author names, emails published on the page)?**
The Actor doesn't seek out personal data — it keeps whatever the site itself already publishes, unmodified. If your target pages publish personal data, you are the data controller under GDPR for that dataset and need your own lawful basis; you can delete the dataset at any time.

**Who is responsible for the target site's terms of service?**
You are. Crawl sites you own or are permitted to ingest; the Actor paces requests, caps concurrency and honours `robots.txt` by default so the target is never degraded, but third-party ToS compliance is your responsibility.

### Keywords

website content crawler rag chunks, embedding ready website scraper, rag chunk feed, website to vector db, mcp ready website crawler, docs crawler for rag, markdown chunker crawler, token aware chunking scraper, website knowledge base crawler, pinecone qdrant website ingestion, llm ready web scraper

### Hashtags

\#RAG #VectorDB #LLM #Embeddings #WebCrawler #Chunking #AI #LangChain #MCP #Apify #DeveloperTools #Markdown

# Changelog

This Actor's version history is a separate document: https://apify.com/leadsbrary/website-rag-chunk-feed/changelog.md

# Actor input Schema

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

Pages or sections to crawl. Each URL is a crawl seed; links found on the page are followed up to maxCrawlDepth.

## `maxCrawlDepth` (type: `integer`):

How many link hops to follow from each start URL. 0 = only the start URLs themselves.

## `maxCrawlPages` (type: `integer`):

Hard cap on pages fetched, including pages that produce no chunk. Protects spending.

## `maxResults` (type: `integer`):

Hard cap on chunk rows pushed to the dataset. The run stops cleanly when reached.

## `sameDomainOnly` (type: `boolean`):

Follow links only on the same hostname as the start URL(s).

## `includeUrlGlobs` (type: `array`):

Glob patterns a URL must match to be crawled, e.g. https://docs.example.com/guide/\*\*. Empty = no restriction.

## `excludeUrlGlobs` (type: `array`):

Glob patterns that exclude a URL from crawling (changelogs, archives, locale duplicates).

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

Honour the target site's robots.txt disallow rules. Leave on unless you own the site.

## `chunkStrategy` (type: `string`):

heading-recursive: split on markdown headings first, then recursively on paragraphs/words to fit chunkSize. recursive: ignore headings. page: one chunk per page (no splitting).

## `chunkSize` (type: `integer`):

Target chunk size in tokens of the selected tokenizer.

## `chunkOverlap` (type: `integer`):

Tokens of the previous chunk repeated at the start of the next one. Must be smaller than chunkSize.

## `minChunkChars` (type: `integer`):

Chunks shorter than this (navigation leftovers, empty sections) are dropped instead of polluting the index.

## `tokenizer` (type: `string`):

Tokenizer used for chunkSize, chunkOverlap and tokenCount.

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

Format of the chunk text: cleaned markdown or plain text.

## `includePageMetadata` (type: `boolean`):

Include per-page metadata (description, author, publishedAt, modifiedAt) on every chunk row.

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

Only needed if the site you crawl rate-limits datacenter traffic.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://docs.python.org/3/tutorial/introduction.html"
    }
  ],
  "maxCrawlDepth": 0,
  "maxCrawlPages": 5,
  "maxResults": 50,
  "sameDomainOnly": true,
  "includeUrlGlobs": [],
  "excludeUrlGlobs": [],
  "respectRobotsTxt": true,
  "chunkStrategy": "heading-recursive",
  "chunkSize": 512,
  "chunkOverlap": 64,
  "minChunkChars": 120,
  "tokenizer": "cl100k_base",
  "outputFormat": "markdown",
  "includePageMetadata": true,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# 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": [
        {
            "url": "https://docs.python.org/3/tutorial/introduction.html"
        }
    ],
    "maxCrawlDepth": 0,
    "maxCrawlPages": 5,
    "maxResults": 50,
    "includeUrlGlobs": [],
    "excludeUrlGlobs": [],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("leadsbrary/website-rag-chunk-feed").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://docs.python.org/3/tutorial/introduction.html" }],
    "maxCrawlDepth": 0,
    "maxCrawlPages": 5,
    "maxResults": 50,
    "includeUrlGlobs": [],
    "excludeUrlGlobs": [],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("leadsbrary/website-rag-chunk-feed").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://docs.python.org/3/tutorial/introduction.html"
    }
  ],
  "maxCrawlDepth": 0,
  "maxCrawlPages": 5,
  "maxResults": 50,
  "includeUrlGlobs": [],
  "excludeUrlGlobs": [],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call leadsbrary/website-rag-chunk-feed --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,leadsbrary/website-rag-chunk-feed"
        }
    }
}
```

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/PEZga1sFRSzLhMYXx/builds/T4Jjqz24WMbx7S0x7/openapi.json
