HTML data extractor API
Extract data from a web page or raw HTML with CSS selectors into JSON — lists, attributes, number / date filters, pagination — or turn a page into RSS.
Send a public url (or html) and a fields map. A value is a CSS selector with an optional attribute and filters: "h1", "a.more@href" (links and image sources become absolute URLs), ".price | number". A name ending in [] returns every match; an object {"selector": ".product", "fields": {...}} returns a list of records, with selectors relative to each item. Filters: trim, lower, upper, oneline, number (150.000 ₫ → 150000), int, date (dd/mm/yyyy → ISO), url, remove_accents, regex:… (first group), replace:a=>b, split:,, default:….
next (a selector for the "next page" link) with max_pages (up to 3 on Free, 5 on paid plans) follows pagination on the same site and concatenates the lists. format=rss or json_feed turns a page without a feed into one: feed = {"item": "article", "title": "h2", "link": "a@href", "date": "time@datetime", "summary": "p", "image": "img@src"}.
Fair use: pages are fetched with our bot identity (APIBoxBot), robots.txt is respected (disallowed paths are refused), JavaScript is not executed, no cookies or logins, and sites whose terms forbid automated extraction or that sit behind captchas (search engines, social networks, large marketplaces, tax / business-registry portals, gold / fuel price and power-outage pages) are blocked. Pages up to 2 MB.
Markdown · OpenAPI · Postman · llms.txt
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
url | body|query | string | no | Public page to fetch (or send html). | |
html | body | string | no | Raw HTML instead of a URL (with optional base_url). | |
fields | body|query | object | yes | Map of name → selector[@attr] | filter or {selector, fields}. | |
next | body|query | string | no | Selector of the next-page link (pagination). | |
max_pages | body|query | number | no | 1 | Pages to follow with next (Free 3, paid 5). |
format | body|query | string | no | json | json, rss or json_feed. |
feed | body|query | object | no | Feed mode selectors: item, title, link, date, summary, image, author. | |
limit | body|query | number | no | 500 | Maximum matches per list (1-2,000). |
Example
curl -X POST "https://apibox.io.vn/v1/html-extract" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"html":"<h1>Cửa hàng</h1><div class=\"sp\"><a href=\"/p/1\">Áo thun</a><span class=\"gia\">150.000 ₫</span></div><div class=\"sp\"><a href=\"/p/2\">Quần jean</a><span class=\"gia\">1.250.000 ₫</span></div>","base_url":"https://shop.example.vn/","fields":{"tieu_de":"h1","san_pham":{"selector":".sp","fields":{"ten":"a","url":"a@href","gia":".gia | number"}}}}'const res = await fetch('https://apibox.io.vn/v1/html-extract', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"html": "<h1>Cửa hàng</h1><div class=\"sp\"><a href=\"/p/1\">Áo thun</a><span class=\"gia\">150.000 ₫</span></div><div class=\"sp\"><a href=\"/p/2\">Quần jean</a><span class=\"gia\">1.250.000 ₫</span></div>",
"base_url": "https://shop.example.vn/",
"fields": {
"tieu_de": "h1",
"san_pham": {
"selector": ".sp",
"fields": {
"ten": "a",
"url": "a@href",
"gia": ".gia | number"
}
}
}
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/html-extract",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"html": "<h1>Cửa hàng</h1><div class=\"sp\"><a href=\"/p/1\">Áo thun</a><span class=\"gia\">150.000 ₫</span></div><div class=\"sp\"><a href=\"/p/2\">Quần jean</a><span class=\"gia\">1.250.000 ₫</span></div>", "base_url": "https://shop.example.vn/", "fields": {"tieu_de": "h1", "san_pham": {"selector": ".sp", "fields": {"ten": "a", "url": "a@href", "gia": ".gia | number"}}}},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/html-extract');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"html":"<h1>Cửa hàng</h1><div class=\\"sp\\"><a href=\\"/p/1\\">Áo thun</a><span class=\\"gia\\">150.000 ₫</span></div><div class=\\"sp\\"><a href=\\"/p/2\\">Quần jean</a><span class=\\"gia\\">1.250.000 ₫</span></div>","base_url":"https://shop.example.vn/","fields":{"tieu_de":"h1","san_pham":{"selector":".sp","fields":{"ten":"a","url":"a@href","gia":".gia | number"}}}}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"url": null,
"title": null,
"pages": 1,
"counts": {
"san_pham": 2
},
"data": {
"tieu_de": "Cửa hàng",
"san_pham": [
{
"ten": "Áo thun",
"url": "https://shop.example.vn/p/1",
"gia": 150000
},
{
"ten": "Quần jean",
"url": "https://shop.example.vn/p/2",
"gia": 1250000
}
]
}
}
Use cases
- Pull product names and prices from your own shop pages into a sheet
- Make an RSS feed for a news or notice page that has none
- Collect event, job or tender listings from public pages for n8n / Make
- Parse HTML you already downloaded with the same selector rules
FAQ
Why is a site refused?
Either its robots.txt disallows our bot on that path, or it is on our list of sites that forbid automated extraction or use captchas / logins. We do not bypass either.
Does it run JavaScript?
No. Content that a page loads with JavaScript after it opens is not visible; look for the site’s API or feed instead.
How is this different from page-watch?
html-extract returns structured data on each call; page-watch stores a snapshot and alerts you when it changes.
Related APIs
URL Metadata
Fetch any URL and get its title, description, Open Graph and Twitter Card tags, favicon, canonical, feeds and JSON-LD as JSON.
H:HTTP Headers
See the HTTP status and every response header of a URL, with a summary of security headers like HSTS, CSP and X-Frame-Options.
301Redirect Checker
Follow every 301, 302, 307 and 308 redirect of a URL and get the full chain with status codes, the final URL and the number of hops.