Data extraction: turn any page into structured JSON
Describe the fields you want with CSS selectors and the data parameter does the rest — no headless browser to run, no HTML to parse. Works on the free tier; Pro adds automatic proxy resolution when targets fight back.
Each key inside data becomes a field in the response — validated by type on the way out.
The data object you send is the shape of the JSON you get back. Point a selector at an element, pick what to read with attr — text, an attribute, HTML, even markdown — and validate the result with type: url, number, date, image, and more.
Pages change and selectors break — so a rule can also be an array of fallbacks, tried in priority order until one succeeds. When CSS alone is not enough, evaluate runs a JavaScript function against the page to compute the value.
Microlink runs the headless browser, waits for the content, applies your rules, and returns clean JSON — the same request can also capture the screenshot, render the PDF, or read the metadata of the page.
From a single field to a full collection
Every extraction rule is built from the same five properties — selector, selectorAll, attr, type, and evaluate. Combine them to match the shape of the data you are after.
href or src, inner HTML, or a markdown rendition. Add type to validate and normalize the value before it reaches your code.attr rules inside and each match becomes a structured object — title, link, price — instead of a flat string. One request, the whole listing.type validation and fallback arrays so extraction keeps working when pages change.Your first extraction, two rules
Each key inside data is a field in the response. Here headline reads the text and link reads the href, validated as a URL — no parsing on your side.
import mql from '@microlink/mql'
const { data } = await mql('https://news.ycombinator.com', {
data: {
headline: { selector: '.titleline > a', attr: 'text' },
link: { selector: '.titleline > a', attr: 'href', type: 'url' }
}
})
console.log(data.headline, data.link)Every match, as structured objects
selectorAll turns the rule into an array; nested attr rules run against each match. Add meta: false to skip metadata and get just your fields back.
const { data } = await mql('https://news.ycombinator.com', {
data: {
stories: {
selectorAll: '.athing',
attr: {
title: { selector: '.titleline > a', attr: 'text' },
href: { selector: '.titleline > a', attr: 'href', type: 'url' }
}
}
},
meta: false
})Pro adds the unblocking layer
Extraction rules are half the job — the other half is getting the page to render at all. Every Pro plan bundles the pieces that keep scraping working in production: automatic proxy resolution against antibots, custom headers for login walls, and configurable cache TTL so repeated extractions cost nothing.
EPROXYNEEDED is the signal a target requires it; a response served through the proxy layer carries x-fetch-mode: fetch-proxy. You can also bring your own exit IP with the proxy parameter.x-api-header-cookie as a request header and Microlink forwards the original cookie to the target — the credential rides inside HTTPS and never touches the URL.Selectors in, JSON out.
Prototype on the free tier — 25 requests a day, no API key. When you go to production, Pro plans start at 14,000 requests per month and bundle proxy resolution, custom headers, and configurable TTL.
Do I need to run a headless browser?
data object and receive JSON back.prerender and wait for dynamic elements with waitForSelector before the rules are applied — see the page preparation guide.Is data extraction available on the free plan?
selector, selectorAll, attr, type, evaluate, fallbacks — works on the free tier, which includes 25 requests per day without an API key.What happens when a selector doesn't match?
type validation — for example og:title, then title, then the first h1.Can I scrape sites behind Cloudflare or DataDome?
EPROXYNEEDED; proxied responses carry x-fetch-mode ending in -proxy. See how the proxy works.Can I extract data behind a login?
x-api-header-cookie (a Pro feature). The credential travels inside HTTPS request headers, never in the URL, so it does not end up in logs or embeds.How does caching affect what I pay?
ttl (from 1 minute to 31 days) and serve stale content while revalidating with staleTtl — the caching guide shows the patterns for recurring extraction jobs.Can I transform values during extraction?
evaluate property runs a JavaScript function against the page and uses its return value as the field — useful for computed values, JSON embedded in scripts, or anything CSS selectors cannot reach.type so the output is validated before it reaches your code — see the data reference. When a single rule is not enough, browser functions run your code with full Puppeteer access.