Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:1broseidon Ketch BFS Crawl

From Leeroopedia
Knowledge Sources
Domains Crawl, Graph_Traversal
Last Updated 2026-10-27 00:00 GMT

Overview

A breadth-first traversal of same-host links from a seed URL, bounded by a max depth and a worker pool, that reuses the shared scrape pipeline for each page.

Theoretical Basis

BFS explores pages in order of distance from the seed: depth-0 pages first, then their same-host links at depth 1, and so on, up to `opts.Depth`. The crawler keeps a mutex-guarded `visited` map for dedup and a buffered work channel drained by a worker pool (default 8). Each enqueued item is normalized, filtered (allow substrings / deny regexps), validated, and rewritten before it joins the queue, so the visited-set and cache key are canonical.

Link discovery runs only for BFS (not sitemap mode): the page's goquery doc (reused from the scrape) yields same-host links, which are enqueued at `parent.depth+1`. A `Result` is delivered per page via a callback, so foreground (stream to stdout), background (write status JSON), and MCP (collect with caps) modes share one engine.

Sitemap mode seeds the queue from the sitemap's URLs at depth 0 instead of discovering links, so a site that exposes a sitemap is crawled without link parsing.

Usage

Use when you need to gather many pages from one site in a bounded, deduplicated traversal. Use sitemap mode when the site publishes one. Bound with depth + concurrency + filters to keep the crawl focused.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment