Web, pages and documents logo

Self-Healing Scraper & DOM-to-JSON Compiler

$0.40 USDC per call · Developer and security · POST /api/v1/heal-scraper · Id heal-scraper

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

FieldTypeRequiredDescription
urlstring; length 0..2048noPage to fetch. Provide url or html.
htmlstring; length 0..1500000noRaw HTML to use instead of fetching.
targetSchemaobjectyesJSON 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.
previousBrokenSelectorsobjectnoMap 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.

FieldTypeRequiredDescription
source_urlone ofnoFinal fetched URL, or null when html was supplied.
healedbooleannoTrue when every field fills at least 4 in 5 records (single record: filled) and the data validates against targetSchema.
decidedBystring; one of "previous_selectors", "repaired_selectors", "structured_markup", "llm"noWhich stage produced the returned spec; all but llm make no model call. With llm, only the fields in llmFields were sent to the model.
deterministicbooleannoTrue when no model call was made: replay, cosmetic repair, or structured markup satisfied the schema.
llmCallsintegerno
llmFieldsarray<string>noFields the model was asked to solve (empty when deterministic).
repairsarray<object>noPrevious selectors changed to survive cosmetic drift: hashed or utility classes, :nth-child positions.
dataanynoExtracted data shaped like targetSchema.
selectorMapobjectno
specobjectno
validationobjectno
extractorCodestringnoStandalone TypeScript module exporting extract(html).
page_structure_notesstringno

Pay and connect

Available through: x402 (USDC on Base), MCP, RapidAPI, Apify.

Machine-readable