Skip to content

data

Type: <object>
It enables specific data extraction over the target url, turning Microlink API into a powerful web scraping tool.

Interactive Code Editor

Test API requests with multiple programming languages. Edit code, execute requests, and view responses in real-time.

The data extraction needs to be defined at least with a CSS selector.

Response structure

The extracted data will be part of the data payload in the response:

Rule properties

Each data rule accepts the following properties:
PropertyTypeDescription
selectorstringCSS selector to target the element
selectorAllstringCSS selector to target multiple elements
attrstringHTML attribute to extract (e.g., href, src)
typestringData type for validation (string, number, date, image, url, etc.)
evaluatefunctionJavaScript function to transform the extracted value

Extracting multiple fields

You can extract multiple data fields in a single request:

Interactive Code Editor

Test API requests with multiple programming languages. Edit code, execute requests, and view responses in real-time.

Extract title, link, and score from Hacker News.

Extracting collections

Use selectorAll to extract multiple matching elements as an array:

Interactive Code Editor

Test API requests with multiple programming languages. Edit code, execute requests, and view responses in real-time.

Extract all story titles as an array.

Nested data extraction

For complex DOM structures, use nested rules to organize your data hierarchically:

Interactive Code Editor

Test API requests with multiple programming languages. Edit code, execute requests, and view responses in real-time.

Fallback values

Define fallback rules to ensure data extraction succeeds even when the primary selector fails:

Interactive Code Editor

Test API requests with multiple programming languages. Edit code, execute requests, and view responses in real-time.

Try multiple selectors in order until one succeeds.
You can read the Microlink Query Language documentation to learn more about defining data extraction rules.