# agent402.tools HTML CSS Selector

> agent402.tools HTML CSS Selector is a paid API for AI agents from agent402.tools, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-15).

Run a CSS selector query against a raw HTML string and return matching elements with their text, attributes, and optionally outerHTML

## Facts

- Endpoint: POST https://agent402.tools/api/html-select
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agent402-tools-html-css-selector-e4cdb557
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_LxvUxTsAvt5jsn-ImXApT

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability agent402-tools-html-css-selector-e4cdb557 -d '<json body>'
```

Example prompt: I have this HTML snippet from a product page — can you run the CSS selector '.price' against it and return the text and attributes of up to 50 matches? Here's the HTML: <div class='price'>$19.99</div><div class='price'>$24.99</div>

## When to prefer this

Use this endpoint when you already have the raw HTML content and need a deterministic, structured way to extract elements — CSS selectors are far more reliable and readable than regex for HTML parsing. Prefer this over regex-based extraction for any structured HTML querying, and use it as a post-processing step after fetching or rendering a page (e.g. after calling /api/render).

## Known failure modes

- Invalid or unparseable CSS selector returns an error
- HTML string exceeds 5MB size limit
- limit parameter outside 1-200 range is rejected
- Malformed HTML may cause unexpected match results or empty results
- No matches found returns an empty array without error

## How this service works

Run a CSS selector against an HTML string and return the matches (text, attrs, and optionally outerHTML for each). The deterministic alternative to regex when you already have the HTML and know the selector - pairs with /api/render or any page you've fetched yourself.

## Output

A list of matched elements, each containing the element's inner text, a map of its HTML attributes, and optionally its full outerHTML — up to the specified limit (default 25, max 200). If the `attr` parameter is set, only the value of that specific attribute is returned per match, keeping responses compact.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "attr": {
   "type": "string",
   "description": "When set, return only this attribute's value per match (e.g. \"href\", \"data-id\") - keeps responses compact"
  },
  "html": {
   "type": "string",
   "description": "Raw HTML string to query (max 5MB)"
  },
  "limit": {
   "type": "number",
   "description": "Max matches to return, 1-200 (default 25)"
  },
  "selector": {
   "type": "string",
   "description": "CSS selector (e.g. \"h1\", \".price\", \"article > p:first-of-type\")"
  },
  "includeHtml": {
   "type": "boolean",
   "description": "Include outerHTML of each match (default false - text + attrs only)"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "count": 2,
  "matches": [
   {
    "text": "One",
    "attrs": {}
   },
   {
    "text": "Two",
    "attrs": {}
   }
  ]
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agent402-tools-html-css-selector-e4cdb557/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.tools](https://www.zero.xyz/host/agent402.tools/llms.txt)
