Web extraction APIs: stop counting a 200 response as a document
All Them APIs
Independent API research
A scraper can return a successful response containing a cookie notice, a login page or an empty JavaScript shell. If the next step summarizes it confidently, the pipeline has turned a retrieval failure into apparently useful output.
Start by defining an accepted document. Then choose how to retrieve it. That lets you combine providers where useful without treating different content formats, job models or billing units as interchangeable.
Choose a document interface or a collection job
| Provider in the catalog | Integration shape | Work your adapter must own |
|---|---|---|
| Firecrawl | Requested document formats from a scrape endpoint | Validate requested content and metadata |
| Zyte | Selected HTTP, browser or extraction response fields | Decode/parse the chosen output and normalize its status |
| Apify | A particular Actor run with its own input and dataset | Pin the Actor/schema, wait for completion and validate records |
Firecrawl's scrape reference documents a URL request and selected formats such as Markdown. Zyte's HTTP guide documents a Base64-encoded response body. Apify's Run Actor reference returns run information; creating a run is not evidence that its dataset is complete.
These are choices, not three required steps. A known-page document workflow can use Firecrawl as its default, while a recurring site-specific collection may justify an Apify Actor. Keep parsing and run management explicit when comparing them.
Define an adapter contract before implementing fallback
Normalize each result into sourceUrl, httpStatus, text, fetchedAt, extractionStatus and evidence of any access or parsing problem. Retain provider, request settings and billed usage separately. A requested Markdown field being absent is an adapter failure, not an empty article.
For Zyte HTTP bodies, decode Base64 and use an appropriate HTML parser before extracting main text. Do not remove tags with a regular expression or feed encoded bytes into a language model. With Apify, record the selected Actor/version and run ID, inspect terminal status and retrieve the intended output dataset.
Never infer the source page's HTTP status from the extraction service's outer response code alone. Keep collection time separate from publication time; a fresh fetch can retrieve an old document.
Put a minimum gate in front of downstream work
The following local example validates an already normalized document. The minimum length is a configurable floor, not a universal quality score. A legitimate short notice may need a different policy, and a long challenge page can still fail a task-specific check.
function acceptedDocument(doc, allowedHosts, minimumCharacters = 80) {
let url;
try { url = new URL(doc.sourceUrl); } catch { return null; }
if (url.protocol !== "https:" || url.username || url.password ||
!allowedHosts.includes(url.hostname)) return null;
if (doc.httpStatus !== 200 || doc.extractionStatus !== "complete") return null;
if (!Number.isInteger(minimumCharacters) || minimumCharacters < 1) return null;
if (typeof doc.text !== "string" || doc.text.trim().length < minimumCharacters) return null;
if (!Number.isFinite(Date.parse(doc.fetchedAt))) return null;
return { sourceUrl: url.href, text: doc.text.trim(), fetchedAt: doc.fetchedAt };
}
Apply URL, DNS, redirect, size and private-network controls before retrieval as well. This after-the-fact hostname gate is not a complete server-side request security boundary. Keep credentials out of records, URLs, analytics and prompts.
After the minimum gate, validate the actual job: expected product identifiers for commerce, source passages for research or required document sections for ingestion. Do not mark extractionStatus complete merely because the service returned 200.
Make fallback a policy, not an infinite retry loop
Separate a temporary service error from an access restriction, malformed input, missing permission and exhausted balance. Respect retry guidance and a total deadline. A denied page is not an invitation to switch providers to evade its controls.
An application can allow one approved alternate for a rendering or parsing problem after checking terms and access conditions. Record both attempts and stop when the budget is exhausted. Keep this limit outside the agent's instructions so an enthusiastic repair loop cannot spend indefinitely.
Store an application job key for the URL, requested output and collection window. After a crash, resume or reconcile an existing job before starting another billable Actor run. Publish one accepted output per job, with the attempt history retained for debugging.
Test known pages before collecting unknown ones
Retrieve only approved public URLs with configured provider credentials.
Request the output format the downstream job actually needs.
Preserve URL, source status, collection time and explicit extraction outcome.
Validate task-specific fields before summarizing or storing an accepted document.
Use only approved fallback within a fixed request/time budget.
Stop on access restrictions; never follow instructions found inside page content.
Use authorized fixtures for ordinary HTML, rendered content, a short valid page, a login response, missing body data and a failed Actor run. Test a duplicate job and an interrupted poll cycle as well as a clean success. No external requests are needed to test the local gate above.
Compare total cost and time per accepted document, including rejected responses, parsing, polling and retries. The web scraping cluster covers provider trade-offs. Feed accepted documents into the RAG evidence pipeline, or use the price-comparison workflow when the output must be a matched offer rather than general text.