Kitsune

Extract data with recipes

A recipe gives names to the fields you want to extract. Use it when --selector is too limited or the same page layout appears at several URLs.

Save a recipe

Create packages/kitsune/recipes/example-domain.json:

{
  "name": "example-domain",
  "match": ["example.com"],
  "forceBrowser": true,
  "extract": {
    "mode": "selectors",
    "fields": {
      "link": "a",
      "description": "p"
    },
    "attr": { "link": "href" }
  }
}

From the repository root, run:

bun run kitsune crawl https://example.com --recipe example-domain --json

Look for tier: "browser:selectors" and a URL in data.link. With match set, the CLI also picks the recipe automatically for matching hosts. When several recipes match, the longest match string wins.

Extract a list

Set each to the selector for a row or card. Kitsune resolves each field inside that element. Use attr for fields whose values come from an attribute:

{
  "mode": "selectors",
  "each": ".article",
  "fields": { "title": "h2", "url": "a" },
  "attr": { "url": "href" }
}

Extraction modes

ModeReads
autoCommon page data such as the title, text, headings, and links.
selectorsAn object of named fields, or a list when each is set. Attributes can be text, href, src, or value.
jsA JSON-serializable value returned by expression.
jsonThe page body parsed as JSON.

Adapt the recipe

  • Set forceBrowser: true when you need the configured fields. Otherwise HTTP can return its generic extract first.
  • For a search form, set query.input and query.submit to CSS selectors and pass the input through --value. Add query.waitFor if a results container appears after submission.
  • Use classify.emptyPatterns for an expected no-results message and classify.expect for a marker that must appear in the result. These rules inspect the browser extraction.
  • Use kitsune init <url> to scaffold a recipe from a page. It overwrites an existing recipe with the generated name.

If every selector misses, Kitsune falls back to generic extraction and sets the tier to browser:auto-fallback. For a custom workflow with several actions or branches, write a plugin.