{"uid":"cap_LxvUxTsAvt5jsn-ImXApT","slug":"agent402-tools-html-css-selector-e4cdb557","name":"agent402.tools HTML CSS Selector","description":"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.","url":"https://agent402.tools/api/html-select","method":"POST","headers":{},"bodySchema":{"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)"}}},"responseSchema":{"type":"json","example":{"count":2,"matches":[{"text":"One","attrs":{}},{"text":"Two","attrs":{}}]}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_k3NAA9UE5CAk7HayUq2xI","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Run a CSS selector query against a raw HTML string and return matching elements with their text, attributes, and optionally outerHTML","exampleAgentPrompt":"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>","exampleUseCases":null,"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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).","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T00:44:43.032Z","isFirstParty":false}