A crawl of a large site returns whatever it can reach: archive pages, old versions, translated copies and navigation, and every page it returns costs a credit. This tutorial avoids that. We map the site, sample its paths, choose include and exclude patterns and a page limit, run a bounded crawl on the pages you want, and read the crawl report to see what you paid for.
If you haven't used the Spidra Python SDK before, the Python tutorial covers the install and your API key. For the options of a crawl in depth, see the Crawl API guide. This post is the plan around it.
Know what a crawl costs before you start
The cost of a crawl follows a few rules you can write down before you run anything:
- A page the crawl returns costs 1 credit.
- Navigation pages (read only to find the pages you asked for), failed pages and failed crawls are free.
- A schema or transform instruction adds AI tokens, about 1 credit per 3,300 input tokens or 400 output tokens, summed for the job and rounded up.
- A CAPTCHA solved costs 5 credits.
- A Map costs 1 credit, whatever the number of URLs.
- Re-extracting pages a crawl has already saved costs tokens only.
So a crawl with no schema costs at most max_pages credits, and anything else is that plus tokens. max_pages counts pages returned, and the largest value you can set depends on your plan: 100 on Free, 1,000 on Starter, 5,000 on Builder and 10,000 on Pro. Check the pricing page for what your plan allows. The rest of this tutorial is about keeping the pages returned to the ones you want.
Map the site once and count where its pages live
A Map reads the sitemap and the links on the pages and returns the URLs without fetching them. Before choosing anything, group the URLs by their first path segments to see where the pages live. We'll use the Python docs, a large public site with several versions and many translations:
# plan_crawl.py
import os
import random
from collections import defaultdict
from urllib.parse import urlsplit
from spidra import Spidra
SITE = "https://docs.python.org/3/"
SAMPLES_PER_GROUP = 2
client = Spidra(api_key=os.environ["SPIDRA_API_KEY"])
def group_of(url, depth=2):
parts = [p for p in urlsplit(url).path.split("/") if p]
return "/" + "/".join(parts[:depth])
site = client.map(SITE, limit=1000)
print(f"{site.total} URLs mapped, {site.scanned} scanned, sources: {site.sources}")
groups = defaultdict(list)
for link in site.links:
groups[group_of(link.url)].append(link.url)
biggest = sorted(groups.items(), key=lambda item: -len(item[1]))[:8]
for prefix, urls in biggest:
print(f"{len(urls):>5} {prefix}")
On a site like this, versions (/3.12/, /3.11/) and languages (/fr/3/, /ja/3/) show up as groups of their own. Each is a copy of pages you may already have, and a crawl that wanders into one pays for them.
Count the target pages with a second Map
A Map with a search returns only the URLs related to your words, best matches first. That gives you the number of target pages, which becomes the page limit:
# count_target.py
import os
from spidra import Spidra
client = Spidra(api_key=os.environ["SPIDRA_API_KEY"])
site = client.map("https://docs.python.org/3/", search="asyncio", limit=20)
print(site.total, "URLs matched,", site.scanned, "scanned, from", site.sources)
Output:
21 URLs matched, 556 scanned, from {'sitemap': 7, 'pages': 549}
Of 556 URLs, 21 relate to asyncio. The numbers move a little between runs, so treat them as a guide to the size of the job and not as an exact count.
Sample each path group before you crawl it
A path that looks right can hold the wrong pages. The second half of plan_crawl.py scrapes two random pages from each group as Markdown, and prints each page's size and first line. It's a few credits, and it tells you what a group contains before a crawl pays for all of it:
rng = random.Random(1)
picked = {url: prefix for prefix, urls in biggest for url in rng.sample(urls, min(SAMPLES_PER_GROUP, len(urls)))}
batch = client.batch_scrape(list(picked), extract_content_only=True)
for item in batch.items:
text = (item.result or "").strip()
first_line = text.splitlines()[0][:50] if text else "(empty)"
print(f"{picked.get(item.url, '?'):<22}{len(text):>7} chars {first_line}")
Read the first lines. A group whose samples are all the pages you want is a target. One whose samples are contents pages, indexes or short stubs is navigation, and one that repeats pages from another group is a copy.
Turn the sample into a plan
The plan is a small JSON file whose keys are the crawl's parameters. Here's one for the asyncio reference pages:
{
"base_url": "https://docs.python.org/3/library/asyncio.html",
"crawl_instruction": "Individual Python asyncio reference pages",
"crawl_entire_domain": true,
"include_paths": ["/3/library/asyncio*"],
"exclude_paths": [],
"max_pages": 5
}
base_urlis where the crawl starts. A crawl stays under the start URL's path, so start in the part of the site you want.crawl_entire_domainis on here because the asyncio pages are siblings of the start page, and not below it. Turn it on only when you need it, and pair it with a path filter.include_pathsis a hard boundary. The instruction steers the crawl, but only paths fence it.exclude_pathsremoves whole groups, such as/fr/*or/3.11/*. Use it when a group you sampled turned out to be a copy.max_pagesis the ceiling. Start low. It comes from the second Map (21 matches), and a first run uses 5.
A path filter is the cheaper fence because it adds no AI work. A schema does, and its token credits grow with the length of the pages, as the blog crawls below show.
Run a small bounded crawl first
bounded_crawl.py reads the plan, starts the crawl and polls until it finishes. Then it prints the pages asked for and returned, and the credits the job used:
# bounded_crawl.py
import json
import os
import sys
import time
from spidra import CrawlParams, Spidra
plan = json.load(open(sys.argv[1] if len(sys.argv) > 1 else "plan.json"))
client = Spidra(api_key=os.environ["SPIDRA_API_KEY"])
queued = client.start_crawl(CrawlParams(**plan))
job = client.get_crawl(queued.job_id)
while job.status not in ("completed", "failed", "cancelled"):
time.sleep(5)
job = client.get_crawl(queued.job_id)
if job.status != "completed":
sys.exit(f"crawl {job.status}")
details = client.get_crawl_job_details(queued.job_id)
print(f"asked for up to {plan['max_pages']} pages, got {job.total_pages}")
print(f"credits used: {details.credits_used} (tokens in/out: {details.input_tokens}/{details.output_tokens})")
for page in job.result:
print(" ", page.status, page.url)
With these settings a crawl returns the asyncio reference pages: asyncio-runner, asyncio-task, asyncio-stream, asyncio-subprocess and asyncio-queue. The start page, asyncio.html, is a contents page. It's read for its links and not returned, so it doesn't count toward the five or cost a credit. With no schema or instruction to extract, no AI runs and each returned page costs 1 credit.
See how navigation pages and paths change the bill
Descriptions and path filters both keep unwanted pages out, but they cost differently. Here are three crawls of the Spidra blog, each limited to 10 pages:
from spidra import CrawlParams
BLOG = "https://spidra.io/blog"
everything = CrawlParams(base_url=BLOG, crawl_instruction="All pages", max_pages=10)
described = CrawlParams(base_url=BLOG, crawl_instruction="Individual blog posts", schema=SCHEMA, max_pages=10)
fenced = CrawlParams(base_url=BLOG, crawl_instruction="All pages", exclude_paths=["/blog/category/*"], max_pages=10)
Crawl | Pages returned | Credits |
|---|---|---|
"All pages" | The blog index, six category pages, three posts | 10 |
"Individual blog posts" with a schema | Ten posts. The blog index was a navigation page and wasn't charged | 28 (10 for pages, 18 for AI reading long posts) |
"All pages" with | The blog index and nine posts | 10 |
"All pages" means all pages, so seven of the ten credits went to the index and category pages. Describing the page you want fixes that, and so does excluding the path. The exclusion is the cheaper of the two because it adds no AI work, and the crawl report for it showed exclude_pattern: 6. The 18 extra credits in the second crawl are the schema reading long posts. A description is the better fence when unwanted pages can't be told apart by path.
Read the crawl report
Every finished crawl has a report that says how the instruction was understood, how many navigation pages were read for free, and why other pages were skipped. It answers "why didn't it return that page?" and "where did the credits go?":
report = client.crawl_report(queued.job_id).report
print("understood as:", report.understood_as)
print("navigation pages:", report.navigation_pages, "| skipped:", report.skipped_total)
for reason in report.skipped:
print(" ", reason.reason, reason.count)
print("job id:", queued.job_id)
This is the output of those lines for a crawl of the Spidra blog with the instruction "Individual blog posts":
understood as: Individual blog post articles.
navigation pages: 1 | skipped: 46
outside_domain 26
not_relevant 20
job id: 9a9ae00c-672e-4a3a-8982-1f4b554febe6
The skip reasons point to the fix. outside_domain and outside_start_path mean the crawl stayed where you started it. not_relevant means a page didn't match the instruction. On a site with versions and translations you'll also see other_version_or_language and duplicate_page, and exclude_pattern and include_pattern count what your own paths removed. If a page you wanted is skipped, loosen the path or reword the instruction. If pages you didn't want were returned, tighten them.
Change the extraction without recrawling
Fields and prompts are the part you'll change most. Crawl once without a schema, look at the pages, then run the extraction on the saved pages. It doesn't visit the site again, and it costs tokens only:
# reextract.py
import os
import sys
import time
from spidra import Spidra
client = Spidra(api_key=os.environ["SPIDRA_API_KEY"])
queued = client.crawl_extract(sys.argv[1], "The module name and a one-sentence summary of what it is for")
job = client.get_crawl(queued.job_id)
while job.status not in ("completed", "failed", "cancelled"):
time.sleep(3)
job = client.get_crawl(queued.job_id)
for page in job.result:
print(page.url, "|", page.data)
print("credits used:", client.get_crawl_job_details(queued.job_id).credits_used)
Re-extracting three saved pages took 2 credits in total. Trying five different prompts on a crawl you already paid for costs a fraction of five crawls.
Scale up in steps
Once the five pages look right, raise max_pages to the 21 the Map counted and run bounded_crawl.py again. Check that the pages returned match what you expected, that the credits match max_pages (with no schema), and that the report's skip reasons haven't changed. Then go larger.
Spidra holds the most a job could cost when you submit it and returns the unused part when it finishes. If your balance can't cover max_pages, the crawl isn't refused: it runs with a lower limit, and the API's response says so. For a crawl of thousands of pages, crawl_all_pages() reads every page of a finished job, and the limit depends on your plan.
Conclusion
You have a repeatable way to crawl a large site for what you want: a Map to count where the pages live, a sample of each path group, a plan of paths and a page limit, a bounded crawl on raw Markdown, a report that explains what was skipped, and a re-extraction that doesn't pay for the site twice.
The reason this works is how Spidra charges. A Map is one credit however many URLs it lists. A crawl charges for pages returned, not pages visited, so navigation pages, failed pages and failed crawls are free. Path filters fence a crawl with no AI work at all. A crawl without a schema has a ceiling you can read off max_pages, and every job shows the credits it used, in the job details, in the dashboard's Logs and on the Usage page. The report explains every skip, so you improve the next crawl instead of guessing.
The same key covers the rest of an ingestion pipeline. Batch scrape reads up to 50 URLs per request, with failed items free. Search finds pages across the web before you crawl them, and Parse turns PDFs and Office files into Markdown. Browser actions, cookies, Stealth Mode and CAPTCHA solving handle the sites that need them. Every plan includes every feature, with the plans differing in credits, proxy bandwidth, pages per crawl and monitors, so the plan you pick sets the volume and not what you can do. Enterprise limits are custom. Official SDKs cover ten languages, and an MCP server lets AI tools use the same account.
Create a free account at app.spidra.io (300 credits, no card required), set SPIDRA_API_KEY, and run plan_crawl.py on a site you're allowed to crawl. If you plan to ingest at higher volume, the pricing page lists the credits and pages per crawl for each plan.