> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hasdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Structured Data Extraction

Use the `extractRules` parameter to extract specific content from the page using CSS selectors. This is useful when you want structured JSON output without parsing raw HTML manually.

The value is a simple object where each key is the name of the field you want, and the value is the CSS selector used to extract it.

<Tip>
  Use `extractRules` when you need fast, lightweight structured data without running a [full AI model](/apis/web-scraping-api/llm-extraction/).
</Tip>

## Format

```json theme={null}
{
  "fieldName": "css selector"
}
```

Each selector will return the **text content** of the matched element.

## Example: Extract Page Title

```json theme={null}
{
  "title": "h1"
}
```

This extracts the text of the first `<h1>` on the page and returns it under the `title` key.

## Example: Extract Multiple Fields

```json theme={null}
{
  "title": "h1",
  "price": ".product-price",
  "description": ".product-description"
}
```

This returns:

```json theme={null}
{
  "title": "Apple iPhone 14",
  "price": "$799",
  "description": "The latest iPhone with A15 Bionic chip..."
}
```

## Attribute Extraction

You can extract an attribute by using `@attribute` syntax:

```json theme={null}
{
  "image": "img.product-main @src",
  "link": "a.buy-button @href"
}
```

## Notes

* Only the **first match** per selector is returned
* If the selector is not found, the value will be `null`
