Skip to main content

Getting started

Choosing an Approach

When to use crawl, fetch, or extract

4 min read


KLOAKD provides one orchestrator and three low-level methods. Here's how to choose.

Crawl or crawl and extract

A crawl maps the site: it finds the pages and how they link, without pulling data from them. Use it to see what a site has, or to pick the pages you want.

A crawl and extract also gets the items on each page (products, prices, articles) into rows you can download as CSV, NDJSON or JSON. It takes longer than a crawl, because every page it fetches is also extracted.

Both take the same max_depth and max_pages. Before you start either one, ask for an estimate: it says how large the site seems, how many pages would be fetched, how long it may take and how much data it may use. It is free. A crawl's time budget is 15 seconds a page, at least 10 minutes and at most 10 hours (time budget). A crawl that stops at its time budget or its page limit can be continued, with more pages.

Decision tree

  1. Need data from an entire site? → client.crawl() (one call, handles everything)
  2. Need data from a single page? → kolektr.page() (a crawl's max_depth is at least 1; 0 is refused with 422)
  3. Need raw HTML from a single page? → evadr.fetch()
  4. Need to map a site's structure? → webgrph.crawl() (low-level)
  5. Need to bypass anti-bot? → All methods handle this automatically
  6. Need authenticated access? → Pass session_artifact_id to client.crawl(); get one by logging in with your own account
  7. Need a whole site's data as a file (CSV, NDJSON, JSON)? → a crawl-extract job (webgrph.crawl_extract in the SDKs from 0.7.0)
  8. Need to know how big a crawl will be before you start it? → …/webgrph/crawl/estimate (and …/webgrph/crawl-extract/estimate)

Comparison

| | client.crawl() | evadr.fetch() | webgrph.crawl() | kolektr.page() | |--|-----------|-----------|-------------|------------| | Returns | Pages + optional extracted data | Raw HTML | Page hierarchy | Structured records | | Pages | Many (BFS) | 1 | Many (BFS) | 1 | | Anti-bot | Handled per page | Handled | Handled per page | Handled (or reuses a fetch artifact) | | Extraction | Optional via extract_schema | No | No | Yes (schema) | | Polling | No | No (a 202 is followed by the SDK) | No (the SDK waits); start_crawl() to poll yourself | No | | Streaming | crawl_stream() | fetch_stream() | crawl_stream() | No | | Use case | Discover + fetch + extract a site | Get HTML from one page | Map site, find pages | Get structured data from one page |

Common patterns

Before a large crawl: map first, try one page

A crawl of a whole site can use a lot of data. Two ways to spend less:

  • Map the site first (POST …/webgrph/map): see the site's sections and their page counts, then crawl only the sections you want (include_paths) or exact pages (urls). See map the site first.
  • Try one page first: run crawl and extract with urls: [the start page] and check the rows before crawling more.

Either way, a page's extras (images, video, fonts, stylesheets, tracking) are not loaded unless you ask for them (on fetch and extract too), and max_data_mb stops a job at the data you set. The app shows the estimate, the share of your remaining data and the risks before every crawl.

result = client.crawl(
    "https://example.com",
    max_depth=2,
    extract_schema={"title": "css:h1", "content": "css:article"},
)
for page in result.pages:
    print(f"{page.url}: {page.structured_data}")

Pattern 2: Crawl without extraction

result = client.crawl("https://example.com", max_depth=3)
for page in result.pages:
    print(f"  {page.url} — {page.status_code}")

Pattern 3: Fetch a single page

page = client.evadr.fetch("https://protected-site.com")
print(page.html, page.artifact_id)

Pattern 4: Extract from a single page

result = client.kolektr.page(
    "https://example.com/products",
    schema={"name": "css:.product-name", "price": "css:.product-price"},
)

Pattern 5: Authenticated crawl

client.fetchyr.store_credentials("acme", username="user@example.com", password="secret")
session = client.fetchyr.authenticate("acme", target_url="https://example.com/login")

result = client.crawl(
    "https://example.com/dashboard",
    max_depth=2,
    session_artifact_id=session.artifact_id,
    extract_schema={"title": "css:h1"},
)

Pattern 6: Fetch then extract (manual chaining)

page = client.evadr.fetch("https://protected-site.com")
data = client.kolektr.page(
    "https://protected-site.com",
    schema={"title": "css:h1"},
    fetch_artifact_id=page.artifact_id,
)

When to use advanced modules

  • Skanyr — when you want a stored, searchable copy of a site, its APIs and its changes over time
  • Nexus — when you want an extraction program synthesised for a page
  • Parlyr — when you want to describe what you want in natural language
  • Fetchyr — when the page requires login, MFA, or form automation

See Advanced Modules for details.

Was this page helpful?