Skip to main content
To answer questions about a product’s docs with an LLM, you need the docs as clean text chunks, each with the page it came from. This guide crawls a docs section as Markdown (no AI, so 1 credit per page), removes the navigation, and writes chunks to a JSON lines file you can embed. You need pip install spidra and your API key in SPIDRA_API_KEY. The example uses the Python tutorial.

1. Crawl the section as Markdown

Start at the section you want; the crawl stays under that path. With no transform_instruction or schema, each page’s data is its Markdown and no AI runs:

2. Split pages into chunks, without the menus

A crawl returns the whole page, including the site’s navigation. Splitting at headings and skipping sections that are mostly short bullet links removes the menus. Here’s the whole script:
The first line of chunks.jsonl (text shortened):
Ten pages cost 10 credits.

3. Embed and store

Each line has the text and its source, so you can embed text with any embedding model and store url and title as metadata, which lets your app cite the page an answer came from. Re-run the script on a schedule to keep the knowledge base current, or watch the pages with alertOn: "page" to know when they change.

Bigger sites

  • Raise max_pages up to your plan’s limit (100 on Free, up to 10,000 on Pro). The Python SDK’s crawl() reads every page, even past the 100 that GET /crawl/{jobId} holds.
  • Fence the crawl with include_paths=["/3/tutorial/*"] or exclude_paths=["/3/whatsnew/*"] when the section links elsewhere.
  • Pick pages first with Map, then batch scrape them with extract_content_only=True, which removes menus, headers and footers for you.

Good to know

  • The splitter here is deliberately simple: a # comment at the start of a line inside a code block is also treated as a heading. For production, use a Markdown-aware splitter.
  • Pages the crawl read only to find others aren’t returned or charged. If a page you expected is missing, read the crawl report.