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 --jsonLook 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
| Mode | Reads |
|---|---|
auto | Common page data such as the title, text, headings, and links. |
selectors | An object of named fields, or a list when each is set. Attributes can be text, href, src, or value. |
js | A JSON-serializable value returned by expression. |
json | The page body parsed as JSON. |
Adapt the recipe
- Set
forceBrowser: truewhen you need the configured fields. Otherwise HTTP can return its generic extract first. - For a search form, set
query.inputandquery.submitto CSS selectors and pass the input through--value. Addquery.waitForif a results container appears after submission. - Use
classify.emptyPatternsfor an expected no-results message andclassify.expectfor 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.
Save a named set of CSS selectors and reuse it from the CLI.