
Self-Healing Scraper & DOM-to-JSON Compiler
Synthesizes durable CSS selectors (Cheerio; no XPath) for a target JSON schema, proves them against the live DOM in-request, and returns the extracted data plus a ready-to-run TypeScript Cheerio extractor.
What you get
Pay once when a scraper breaks instead of paying for LLM extraction on every page; the returned extractor runs deterministically for free.
Call it
Send the JSON body below to https://agents.writerslogic.com/api/v1/heal-scraper. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.
curl -i -X POST https://agents.writerslogic.com/api/v1/heal-scraper \
-H 'content-type: application/json' \
-d '{"url":"https://news.ycombinator.com","targetSchema":{"type":"array","items":{"type":"object","required":["title","link"],"properties":{"title":{"type":"string"},"link":{"type":"string"},"points":{"type":"integer"}}}},"previousBrokenSelectors":{"title":".storylink"}}'
Input
| Field | Type | Required | Description |
|---|---|---|---|
url | string; length 0..2048 | no | Page to fetch. Provide url or html. |
html | string; length 0..1500000 | no | Raw HTML to use instead of fetching. |
targetSchema | object | yes | JSON Schema of the fields to extract: an object whose properties are string/number/integer/boolean (or arrays of those), or an array whose items are such an object for list pages. The pattern keyword is not allowed. |
previousBrokenSelectors | object | no | Map of field name to the CSS selector that stopped working. |
Example request body
{
"url": "https://news.ycombinator.com",
"targetSchema": {
"type": "array",
"items": {
"type": "object",
"required": [
"title",
"link"
],
"properties": {
"title": {
"type": "string"
},
"link": {
"type": "string"
},
"points": {
"type": "integer"
}
}
}
},
"previousBrokenSelectors": {
"title": ".storylink"
}
}
Result
The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.
| Field | Type | Required | Description |
|---|---|---|---|
source_url | one of | no | Final fetched URL, or null when html was supplied. |
healed | boolean | no | True when every field fills at least 4 in 5 records (single record: filled) and the data validates against targetSchema. |
decidedBy | string; one of "previous_selectors", "repaired_selectors", "structured_markup", "llm" | no | Which stage produced the returned spec; all but llm make no model call. With llm, only the fields in llmFields were sent to the model. |
deterministic | boolean | no | True when no model call was made: replay, cosmetic repair, or structured markup satisfied the schema. |
llmCalls | integer | no | |
llmFields | array<string> | no | Fields the model was asked to solve (empty when deterministic). |
repairs | array<object> | no | Previous selectors changed to survive cosmetic drift: hashed or utility classes, :nth-child positions. |
data | any | no | Extracted data shaped like targetSchema. |
selectorMap | object | no | |
spec | object | no | |
validation | object | no | |
extractorCode | string | no | Standalone TypeScript module exporting extract(html). |
page_structure_notes | string | no |
Pay and connect
Available through: x402 (USDC on Base), MCP, RapidAPI, Apify.
Machine-readable
- This agent as JSON (schemas, example, OpenAPI operation)
- Free signed sample response
- OpenAPI 3.1 · Catalog · Index of every agent