Custom extraction from crawled pages

Content selectors and declarative extraction rules run over retained page bodies, and saved-scan source search finds which pages carry a marker such as a GTM snippet.

What it does

Extraction rules

Rules are plain data, not code: each has a kind (text, attribute, structured, presence or count), a selector and an operator (equals, contains, matches or exists). The matches operator is a bounded glob pattern, not a regular expression. scan-extract runs the rules over retained page bodies with no network and no writes, so you can change a rule and run it again without recrawling. To preview CSS, XPath or regex extractors on HTML you paste in, use custom-extract-sample.

A library of ready-made sets

The common SEO questions do not need hand-written selectors: fourteen rule sets ship with SpiderHead, and scan-extract --preset headings answers from every retained document of the scan while --list-presets shows the catalogue. Presets and your own rules are peers — the same closed declarative grammar (data only, no executable code, no regular expressions) with bounds on match counts and value sizes — so combine freely: a shipped set for the overview, your own rules for the site-specific fields. Agents get the same by name: the MCP tool seo_scan_extract accepts a preset and seo_extraction_presets returns the catalogue. Response codes (a broken image answering 404, for example) stay outside extraction — rules never see statuses; that is audit territory.

  • headings — every heading h1–h6 with its level, plus the total count
  • headings-outline-check — first h1, every h2, the h1 count: a quick one-h1-per-page check
  • images — src and alt of every image, empty alts, images with no alt attribute
  • links — href, anchor text, rel, the nofollow count, external links as their own column
  • structure — the DOM inventory: div, section, article, main/nav/header/footer/aside, tables, forms, iframes, svg
  • sections — headlines inside article and section elements, a content-block inventory
  • inline-css — every inline style attribute, their count, the style block count
  • meta — title, meta description, meta robots, canonical
  • social — Open Graph and Twitter Card tags with their content
  • json-ld — every JSON-LD block plus the @type of each block
  • media — img, iframe, video and source elements with their URLs
  • forms — form actions and methods, button texts, the input inventory
  • tables — table and row counts, header cells
  • breadcrumbs — breadcrumb text across the common markup patterns

Search the saved HTML

scan-content-search finds a string or a regular expression in raw HTML, head markup, body text or the markup matched by a CSS selector. Use it to find which pages carry a marker such as a GTM snippet. It writes the matches to a new local package, so you keep the result.

  • Literal or regex query, raw HTML or rendered DOM
  • Results are read 100 records at a time with scan-content-search-page

Three steps, one saved scan

  1. Crawl once and keep the bodies

    A saved scan keeps complete page bodies within the body-retention limit. Rules and searches then run on that copy, not on the live site.

  2. Run extraction rules offline

    Write rules as JSON with kind text, attribute, structured, presence or count, and operator equals, contains, matches (a glob) or exists. Pass them to spiderhead scan-extract through --input or the MCP tool; nothing is fetched and the result is not saved.

  3. Search the saved HTML for a marker

    scan-content-search finds a literal string or a regex in raw HTML, head markup, body text or a CSS selector, and writes a local package. Read it 100 rows at a time with scan-content-search-page.

Checks in this feature

CheckWhat it meansSeverityEvidence
TITLE_MISSINGTitle element is missing. A rule with kind text on the title selector finds the same gap across the saved scan.CriticalPage URL; the title element is absent or empty
CANONICAL_MISSINGIndexable page has no canonical URL. A presence rule on link[rel=canonical] lists the pages that lack it.ImportantPage URL; no canonical link found
SCHEMA_VALIDATION_ERRORStructured data validation errors. A structured rule with a JSON pointer lets you read the JSON-LD values behind the error.ImportantPage URL and the failing structured data item
STRUCTURED_DATA_MISSINGStructured data is missing on pages where you expect it. A presence rule on the JSON-LD block shows the pages that have none.TipPage URL; no structured data found
LOREM_IPSUM_PLACEHOLDERLorem Ipsum placeholder text appears in the page content area. A content search for the placeholder phrase finds it across the whole scan.ImportantPage URL and the count of placeholder text matches

One command

bash
spiderhead scan-content-search --scan ./scans/audit.sqlite --query gtm.js

Install first: installation guide. Every command also runs as an MCP tool for AI agents.

What you need

  • A saved scan (SQLite) with retained page bodies
  • For extraction: a JSON list of rules, passed through --input or the MCP tool
  • For presets: a set name via --preset instead of a rules file
  • For search: a query string or regex, and a new output folder

Limits

  • Only pages whose body was kept can be searched or extracted
  • Extraction rules have no regex field; use content search for regular expressions
  • A hit shows the code is in the HTML, not that a tag fired for a visitor
  • Rendered content is searchable only if the scan kept a rendered copy

Questions

Does extraction fetch the site again?
No. scan-extract and scan-content-search read the retained bodies in the saved scan file. They never fetch a URL, so you can change a rule and run it again without a new crawl.
If a GTM tag is found, did it fire?
Not necessarily. A search hit shows the tag is in the HTML. It does not prove the tag fired for a visitor. The search reports where the code is present.
What happens if a page body was not kept?
The page is reported as unknown, not as missing. A search never says a marker is absent when the body is not in the scan.
Is the extraction result saved?
scan-extract does not save its result; it prints it for that run. scan-content-search writes a new local package, so you keep its matches.
Can I use regular expressions?
In content search, yes: --kind regex takes a regular expression. If a page exceeds the regex time budget, or the platform cannot enforce one, it is reported as unavailable, not as a non-match. Extraction rules do not accept regex.

Try it on your own site