Developers

Web Scraping API

Reference

Parsing examples

Build an extraction pipeline with selectors, nested records and type conversion.

CSS text extraction

One title field
{
  "title": {
    "_fns": [
      {
        "_fn": "css_one",
        "_args": [
          "h1",
          "title"
        ]
      },
      {
        "_fn": "element_text"
      }
    ]
  }
}

The first function chooses an element. The next function receives that element and returns its text. Fallback selectors belong in the same _args array.

Convert a price

Numeric field
{
  "price": {
    "_fns": [
      {
        "_fn": "xpath_one",
        "_args": [
          "//span[@class=\"price\"]/text()"
        ]
      },
      {
        "_fn": "amount_from_string"
      }
    ]
  }
}

Group fields under a record

Nested product record
{
  "product": {
    "title": {
      "_fns": [
        {
          "_fn": "xpath_one",
          "_args": [
            "//h1/text()"
          ]
        }
      ]
    },
    "links": {
      "_fns": [
        {
          "_fn": "xpath",
          "_args": [
            "//a/@href"
          ]
        }
      ]
    }
  }
}

Nested objects express the output structure. Keep fields small enough to validate independently, especially when a page has optional elements.

Choose a list item

Last selected link
{
  "last_link": {
    "_fns": [
      {
        "_fn": "xpath",
        "_args": [
          "//a/@href"
        ]
      },
      {
        "_fn": "select_nth",
        "_args": -1
      }
    ]
  }
}

Validate the extracted shape

Preserve raw content for debugging when your workflow permits it. Check required field types and parser warnings after target layout changes. An extraction pipeline can finish while a selector matches no content.

Search documentation

Search guides, products and reference pages.