Extraction & formats
Return the whole page as HTML, text, or markdown, or pull out just the fields you name with CSS and XPath selectors.
Output format
The format parameter controls how result.content is shaped:
raw(the default) returns the full HTML exactly as fetched.textreturns the visible text with markup stripped.markdownreturns the page converted to markdown, which is compact and well suited to feeding a language model.
Extraction rules
Add an extractionRules object to pull named fields out of the page instead of (or alongside) the full content. Each key becomes a field in the output; each value is a selector. A rule can be written two ways:
- A plain string is treated as a CSS selector, and the field is the matched element's text content, for example
"title": "h1". - An object for finer control:
{ css | xpath, attr?, all? }. Usecssorxpathto locate the element,attrto read an attribute rather than text, andall: trueto return every match as a list.
{
"clientKey": "capzy_YOUR_KEY",
"url": "https://example.com/product/42",
"renderJs": true,
"extractionRules": {
"title": "h1.product-title",
"price": { "css": ".price", "attr": "data-amount" },
"sku": { "xpath": "//span[@id='sku']" },
"images": { "css": "img.gallery", "attr": "src", "all": true },
"missing": ".does-not-exist"
}
}The extracted fields come back under result.extracted, which has a mode of rules and a data object keyed by your rule names.
{
"errorId": 0,
"status": "ready",
"result": {
"format": "raw",
"engine": "browser",
"extracted": {
"mode": "rules",
"data": {
"title": "Wireless Headphones",
"price": "129.00",
"sku": "WH-42",
"images": [
"https://cdn.example.com/a.jpg",
"https://cdn.example.com/b.jpg"
],
"missing": null
}
},
"elapsedMs": 1830
},
"cost": 0.0112
}null and the rest of the extraction proceeds. One bad rule never fails the whole request, so you can add speculative fields safely. In the example above, missing came back null while every other field resolved.Lists with all
By default a rule returns the first match. Set all: true on the rule object to return every matching element as an array, as shown by images above. Combine it with attr to collect an attribute across all matches, for example every image src in a gallery.
renderJs and a wait condition so the elements your rules target actually exist before extraction runs.Extraction adds a small flat fee per request. See Pricing for the exact cost.