---
title: "Extract data with recipes"
description: "Save a named set of CSS selectors and reuse it from the CLI."
canonical_url: "https://kitsune.carsxe.com/docs/guides/recipes"
markdown_url: "https://kitsune.carsxe.com/docs/guides/recipes.md"
last_updated: "2026-11-24"
x_farming_labs_generated_preamble: true
---

# Extract data with recipes
URL: /docs/guides/recipes
LLM index: /llms.txt
Description: Save a named set of CSS selectors and reuse it from the CLI.

# 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`:

```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:

```bash
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:

```json
{
  "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: 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](/docs/concepts/plugins#writing-one).

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
