domain-links
Latest: v0.1.0
Version 0.1.0 adds an end-to-end guide for discovering links across pages and domains.
- Documents when to use asset, network, batch, sitemap, and spider tools.
- Adds recipes for sitemap and no-sitemap crawling, external-link audits, media and document inventories, and link validation.
- Covers HTTP-only crawling for static sites and browser fallback for JavaScript-rendered pages.
- Adds guidance on batching, caps, robots, throttling, crawl limits, and common failure cases.
/domain-links
Gather links with the smallest number of page loads. The tools are split by boundary, not by link kind, so the recipe matters more than any single call.
Tool map
| Need | Call |
|---|---|
| Everything a single page exposes | webrain_assets {max: 2000} (or webrain_observe {what:"assets"}) — one JS pass: links.internal, links.external, links.other_schemes, images (incl. background), videos, documents, network, and counts |
| Only one class | webrain_assets {only:"links"|"images"|"videos"|"documents"|"network", max: 2000} |
| Every URL the page requested (XHR/fetch/API/CSS/media), one page | webrain_network {op:"log", url, wait_ms} then op:"requests"; add type:"XHR" / filter |
| Every URL the page requested, many pages | webrain_batch {op:"network", urls:[…], concurrency, max} |
| All link classes, many pages | webrain_batch {op:"assets", urls:[…], concurrency, max} |
| Every URL the site publishes | webrain_crawl {mode:"sitemap", url:"https://site"} — pure HTTP, robots → sitemap index → leaves |
| Crawl the internal link graph | webrain_crawl {mode:"spider", seed_url, same_domain:true, max_depth, max_pages, concurrency} |
| Same, static site, no browser | add http_only:true, no_content:true — pooled HTTP GET + scraper, no tab/JS |
| Seed from the published inventory | add seed_from_sitemap:true (works with both spider paths; falls back to the seed URL) |
| Custom one-off | webrain_eval (one page) or webrain_batch {op:"eval"} (many) |
webrain_crawl mode=spider returns one row per page: {page:{url,title,content,error,…}, depth, links:[…]}.
Recipes
1. One page — every link class
{"name":"webrain_assets","args":{"max":2000}}
Read counts first (internal, external, images, videos,
documents, network, scanned). Counts are pre-cap; the arrays are capped
per max. documents = stylesheets, scripts, preloads, iframes, forms,
meta-refresh, manifest; network = Resource-Timing URLs with initiator type,
transfer size and duration. Background images are in images with
kind:"background".
To collect the real network layer instead (API endpoints, lazy-loaded assets),
use webrain_network {op:"log", url, wait_ms:3000} on the same page, then
op:"requests" (it returns status/type/bytes; op:"request" fetches one body).
2. Whole domain, sitemap exists (fastest, no browser)
{"name":"webrain_crawl","args":{"mode":"sitemap","url":"https://site"}}
Then, in batches:
{"name":"webrain_batch","args":{
"op":"assets","urls":["https://site/a","https://site/b"],
"concurrency":6,"max":300}}
Use op:"network" instead when you need request URLs rather than DOM/CSS links.
The sitemap gives the URL inventory; the batch gives every link class on each
page. This is the cheapest path: the sitemap walk is plain HTTP, and the batch
runs one tab per URL only for the pages you actually need.
3. Whole domain, no sitemap
{"name":"webrain_crawl","args":{
"mode":"spider","seed_url":"https://site",
"same_domain":true,"max_depth":3,"max_pages":500,
"http_only":true,"no_content":true,"seed_from_sitemap":true,
"concurrency":8,"respect_robots":true}}
http_only:true uses the pooled HTTP agent + scraper for <a>/<area> — no
tab, no JS, no wait; good for static sites, docs, shops, blogs. The frontier
dedupes on path + sorted query and strips tracking parameters (utm_*,
fbclid, gclid, …), and hash routes (#/x) are kept. seed_from_sitemap
tries robots/sitemap first and falls back to the seed URL.
If pages are JS-rendered (SPA, infinite scroll, framework hydration), run the
same call with http_only:false (browser path) and a smaller
concurrency; use no_content:true to skip text extraction and get links only.
4. External links and mixed internal/external
webrain_crawl follows only the seeds' domain by default
(same_domain:true). To collect external links too, use
webrain_assets on the pages: links.external is returned explicitly, with
counts.external. For a domain-scale external audit, run the sitemap + batch
op:"assets" recipe and merge links.external from every page.
5. Media, CSS backgrounds and documents
webrain_assets covers: <img> (+lazy/srcset/picture), icons/og/twitter,
CSS background-image, <video>/<audio>/posters/sources, known embeds, media
links, file links, plus the documents and network groups. webrain_get_images
is the images-only shortcut. For HLS/DASH or API media, webrain_network sees the
URLs that were actually fetched even when they are not in the DOM.
6. Sitemap-only / link-health
webrain_crawl {mode:"sitemap", url}→ all published URLs.webrain_crawl {mode:"validate", urls:[…]}→ alive/dead probe, no browser.webrain_crawl {mode:"scan", url, max_scrolls}→ infinite-scroll pages, when the links only appear after scrolling.
Speed rules
- Sitemap before spider. A sitemap walk is HTTP-only and removes most of the discovery work. If there is no sitemap, say so and use the spider.
http_only:truefor static pages. No tab, no JS, no 300 ms settle. Switch to the browser only when the page is a JS app.- One JS pass for one page.
webrain_assetsreturns every class in one evaluate; do not callevalonce per class. - Batch, don't loop.
webrain_batch op=assets|networkwithconcurrency(4–8 typical) is for N pages; a per-URL loop re-attaches the browser for every page. - Cap deliberately.
maxtruncates arrays;countsstays true. For a first pass usemax:200; for a full page inventory usemax:2000. - Respect the site.
respect_robots:true;delay_ms/autothrottleon rate-limited origins;max_pages/max_depthbound the crawl;crawl_timeout_secsfor a hard stop.
Robustness rules
- Check
errorper page; a challenge/consent/login page is not a link source. Use real Chrome + a persistent profile/session for protected pages, not the HTTP path. - A sitemap may be missing, gzipped, an index, or stale: the sitemap walk
follows
<sitemapindex>recursively and reportssources; if it returns no URLs, fall back to the spider. http_onlycannot see client-rendered links. If a page returns almost no links or a sparse shell, retry it with the browser path.network/Resource Timing only sees what the page actually requested; DOM/CSS links that were never fetched appear inassetsbut notnetwork. Conversely,assetscannot see API endpoints that only exist in a fetch response — usenetwork/webrain_networkfor those.- Sitemap/spider URLs are candidates, not proof of content: validate before
counting a link as live (
mode:"validate"or a small batch fetch). - Keep the two outputs separate when reporting: internal, external, media, documents, network, and other schemes; a single "all links" number hides which class is missing.
