Skip to content

Lesson 3 of 9 · 23m

Target Cartography and Crawl Budgets

Map entry points, pagination, canonicalization, state, and request cost so the crawl has a bounded shape instead of an infinite frontier.

A crawler without a map becomes a machine for generating duplicates. It follows calendar links, sort permutations, tracking parameters, faceted filters, and session URLs until the frontier is larger than the web it started with. Target cartography is the discipline of describing the useful surface before you consume it.

Draw the navigation graph

Start with seed URLs and classify every discovered link:

seed/list page        /catalogue/page-1.html
detail page           /catalogue/sharp-objects_997/index.html
pagination            page-2.html, page-3.html
sort/filter           ?sort=price&direction=asc
canonical             rel=canonical target or preferred URL
utility               login, cart, search, print, share
out of scope          external domains, mailto, media variants

The question is not merely "can I fetch this URL?" It is "does this URL represent a new entity, a duplicate representation, or a control action?"

Canonicalize before enqueueing

URL normalization prevents explosive duplication. Strip tracking parameters, normalize host casing, remove fragments, sort benign query keys, and respect canonical links only after validating they do not collapse distinct items incorrectly:

TRACKING = {"utm_source", "utm_medium", "utm_campaign", "fbclid", "gclid"}

def canonicalize(url):
    parts = urlsplit(url)
    query = sorted((k, v) for k, v in parse_qsl(parts.query) if k not in TRACKING)
    return urlunsplit((parts.scheme.lower(), parts.netloc.lower(), parts.path, urlencode(query), ""))

Do not blindly drop every query parameter. On many applications the query is the resource identity: ?id=42 and ?id=43 are not duplicates.

Budget the work in entities, not pages

A crawl budget should state the useful output and the maximum acceptable cost:

target entities       1000 book records
expected list pages   50 pages at 20 items each
maximum requests      1100 total
maximum rate          1 request/second
maximum concurrency   2 workers
retry amplification   at most 1 retry for transient 5xx/timeout
stop condition        3 consecutive empty or invalid pages

Without those numbers, a small parser bug can turn into a denial-of-service incident.

Identify statefulness early

Search results, carts, sessions, CSRF tokens, A/B buckets, geolocation, and cookies can all alter what you see. Record whether the URL is sufficient to reproduce the representation. If it is not, decide whether you actually need the personalized state or whether you accidentally copied a browser workflow into a batch crawler.

Build a frontier policy

A disciplined frontier stores:

canonical URL, source/referrer URL, discovery depth
entity type guess, priority, last fetched status/timestamp
content fingerprint or hash when available

That structure makes pause/resume, dedupe, and incident review possible. A FIFO queue of raw strings is how teams lose provenance.

Field notes

  • Calendar and faceted-navigation pages are classic infinite spaces; constrain them explicitly.
  • rel=canonical can be wrong or self-promotional; validate before trusting it for entity identity.
  • Depth limits control exploration but not duplication — canonicalization and entity IDs do that.
  • Track retry amplification separately from planned requests; retries are often the hidden multiplier.
  • A crawl plan should have a stop condition even when everything is working.

Was this lesson helpful?

Sign in to rate