Capture the API calls behind a web page
Many pages load their data from an API. Capture those calls and read the JSON directly.
How it works
- Render the page. Set
js_render: true, because capture only runs in a browser. - Choose the calls. Set
network_captureto aurlslist of patterns, such as/api/search. - Read the bodies. Each matching call comes back in the
networkarray with its status, type and body.
curl -sS https://api.spicrawl.com/v1/scrape \
-H "Authorization: Bearer $SPICRAWL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/search?q=desk",
"js_render": true,
"network_capture": { "urls": ["/api/search"] }
}'spicrawl scrape "https://example.com/search?q=desk" --render \
--network-capture '{"urls":["/api/search"]}'Keep your key in SPICRAWL_API_KEY.
What comes back
An excerpt of the documented response. The page contents are an example.
{
"status": 200,
"credits": 3,
"network": [
{
"url": "https://example.com/api/search?q=desk&page=1",
"status": 200,
"resource_type": "fetch",
"content_type": "application/json",
"body": { "total": 38, "items": [{ "id": 42, "name": "Walnut Desk", "price": 349.0 }] }
}
]
}When to use it
- The page fills itself from an API. The JSON is usually cleaner and steadier than the markup drawn from it.
- Search, listings and feeds. Results often load as one JSON call you can read whole.
- Otherwise, use structured extraction with CSS selectors or a JSON Schema.
Good to know
- Needs
js_render. It adds no credits on top of the 3 for JavaScript rendering. Failed requests cost 0. - Be respectful. Only fetch data you are allowed to use, and follow the site’s terms.
- Pricing: free during the beta, with 1,000 credits a month.
Frequently asked questions
What does network capture do?
It records the network calls a page makes while it loads and returns the ones you ask for, including the response body. That lets you read the JSON the page itself uses, instead of parsing the HTML it draws from it.
How do I choose which calls to capture?
Set network_capture to an object with a urls list of patterns, for example {"urls": ["/api/search"]}. Calls whose URL matches a pattern are returned.
Does it need JavaScript rendering?
Yes. Capture only works when the page is rendered in a browser, so set js_render to true.
Does network capture cost extra?
No. It adds no credits on top of the JavaScript rendering you already pay for, which is 3 credits. Failed requests cost 0.
Should I use it instead of scraping the HTML?
When a page fills itself from a JSON API, reading that JSON is usually cleaner and more stable than parsing markup. Respect the site’s terms and only fetch data you are allowed to use.