ScraperFlyAI-ready Web Data API

developer api

HTML Parser API for Web Scraping source pages

HTML parsing works best when the capture layer returns the right source. ScraperFly helps teams fetch public pages as raw HTML when markup is present, or rendered HTML when JavaScript builds the DOM, so downstream parsers can work from verified response evidence.

Parser-ready markup

Capture reliable HTML before extraction rules depend on it

An HTML parser is only as dependable as the page source it receives. If the request returns a thin shell, a redirect, a blocked fallback, or markup that appears only after JavaScript runs, selectors and extraction rules can fail even when the parser itself is correct.

ScraperFly gives teams a cleaner starting point: fetch public pages as raw HTML when the markup is already present, switch to rendered HTML when the useful DOM is browser-built, and preserve response evidence so parsing decisions are based on the actual page state.

raw HTML rendered DOM selector checks parser input
Engineering team validating captured HTML before downstream web scraping parser rules

What is an HTML parser API for web scraping?

An HTML parser API workflow starts by retrieving a public page and giving your application markup it can inspect. The parser then extracts links, headings, tables, metadata, product cards, article sections, pagination, embedded data, or other page elements from that captured source.

The practical challenge is not only parsing. It is capturing the right version of the page before parsing begins. Some targets expose useful markup in the initial HTML response. Others send an empty app shell and build the DOM in the browser. Some return a different page depending on headers, cookies, region, or routing. ScraperFly handles that capture layer so your parser can work from a verified response instead of brittle browser glue.

Practical takeaway: keep extraction rules in your own pipeline, but let the API deliver the source evidence those rules depend on.

When should the parser use raw HTML or rendered HTML?

Raw HTML is the best starting point when the target sends useful markup immediately. It is lighter, faster to inspect, and easier to compare across samples. Rendered HTML is useful when the initial source only contains a route container, hydration script, placeholder nodes, or late-loaded content that appears after browser execution.

The decision should be per target, not global. If every URL is forced through a browser by default, the workflow becomes heavier before the team knows whether rendering improves the captured source. A better pattern is to fetch source HTML first, compare it with the expected fields, then enable rendering only for pages where the parser cannot see the needed markup.

Parser input Use it when Main advantage Important check
Raw HTML The initial response contains the links, fields, tables, or content blocks. Lightweight and easy to debug. Confirm the markup is present before writing selectors.
Rendered HTML JavaScript builds the useful DOM after the source response loads. Captures the browser-built page state. Use rendering only when it changes the response.
Text or Markdown The downstream workflow needs readable content rather than DOM relationships. Cleaner input for content review, search, and AI workflows. Do not use it when selectors or attributes matter.
JSON metadata The application needs response context for logging, QA, or routing decisions. Exposes operational evidence around the capture. It complements parsing; it does not replace target-specific extraction rules.

What should teams validate before scaling parser rules?

Parser rules often look stable on one sample and then break across a URL set. The fix is to validate response shape before scale: make sure the same sections exist, expected links are present, tables keep predictable structure, pagination is visible, and the response did not silently redirect to a different page type.

ScraperFly helps by keeping the request controls visible. You can compare raw and rendered output, preserve final URL and status, inspect response size, and use screenshots when visual proof matters. That makes selector failures easier to diagnose: the parser can tell whether the target changed, the markup moved, JavaScript was required, or the capture returned the wrong page.

Validation point Why it matters Parser-safe action
Expected container The parser needs a stable section to start from. Check whether raw or rendered HTML contains the container.
Links and pagination Many crawls fail when next-page links are absent or transformed. Verify hrefs and page controls across samples.
Tables and lists Data can shift columns, labels, or nesting between templates. Compare structure before mapping fields.
Status and final URL A parser may receive a login wall, redirect page, or soft block. Log response evidence with each parsed result.
Response format DOM parsing, text ingestion, and visual QA need different outputs. Choose HTML, text, Markdown, JSON, screenshot, or PDF based on the consumer.

Where does ScraperFly fit in an HTML parsing pipeline?

ScraperFly sits before your parser. Your application sends a target URL and a request profile, then receives a response shape your pipeline can use: raw HTML for source parsing, rendered HTML for browser-built pages, clean text or Markdown for content workflows, JSON metadata for diagnostics, or screenshots and PDFs for visual evidence.

That separation is valuable. Your team keeps control over selectors, extraction rules, validation, storage, and business logic. ScraperFly handles the fetch layer, browser rendering when it is actually needed, session and header context, routing options, and response formats. The result is a cleaner boundary between “get the right page source” and “extract the data we care about.”

For a broader view of supported outputs, compare the web scraping API response formats. To test a request profile before writing production code, use the public API Builder.

How can teams keep HTML parsing stable in production?

Production parsing needs evidence, not only selectors. Store the target URL, final URL, status, content type, response size, render setting, timing controls, and chosen output format with each capture. Those fields make it much easier to separate parser mistakes from target changes, delivery problems, and JavaScript rendering gaps.

When the parser starts missing fields, avoid rewriting extraction logic immediately. First inspect whether the captured markup still contains the expected source. If it does, update the parser. If it does not, adjust the request profile: render the page, wait for late content, preserve session state, add legitimate headers, choose country routing, or use stronger delivery for targets that prove they need it.

Practical takeaway: the strongest parser workflow starts with source proof, then changes extraction rules only after the capture layer is verified.

How does this make scraping cheaper to operate?

HTML parsing becomes expensive when teams use the heaviest request profile for every page. ScraperFly supports a more practical path: start with lightweight HTML capture, inspect whether the markup contains useful data, then add browser rendering, waits, sessions, headers, country targeting, premium routing, screenshots, or PDFs only when the target proves those controls improve the result.

This is especially useful for projects with mixed targets. Simple public pages can stay on simple captures. JavaScript-heavy pages can use rendered HTML. Pages that need proof can add screenshot or PDF output. Uneven projects can use pay-as-you-go credits, while predictable production workloads can move to monthly credits when the pattern is clear. The pricing page explains that path in detail.

HTML parser workflow

Fetch reliable HTML before your parser depends on page structure

A parser is only as good as the markup it receives. ScraperFly captures raw or rendered HTML from public pages so selectors, parsing rules, and downstream extraction can start from a verified response.

HTML
Markup first

Capture the page structure your parser needs

Fetch source HTML for simple pages or rendered HTML when JavaScript creates the DOM your parser reads.

format=htmlrender=falserender=true
DOM
Selector proof

Validate selectors on real responses

Compare captured HTML against the fields your parser expects before scaling across a URL set.

selectorsfieldssamples
SAFE
Escalation

Escalate delivery only when markup is missing

Headers, sessions, country routing, rendering, or premium routing become controlled changes instead of default cost.

headerssessionspremium

Request controls for parser-ready HTML

url

The public page whose markup becomes parser input.

format=html

The response shape for raw or rendered HTML.

render

Enable when the useful DOM appears after JavaScript execution.

headers

Add request context when the target response changes by client signal.

cURL example

Generate Markdown with the same request shape you can move into production

curl "https://scraperfly.com/api/v1?url=https%3A%2F%2Fexample.com&format=markdown" \
  -H "apikey: YOUR_API_KEY"

Markup requirements

Check whether raw HTML is enough or browser rendering is needed

Some public pages include useful data in source HTML; others ship a shell and build content in the browser. Mapping that difference early keeps parser work lighter and more predictable.

Raw HTML response mapped to visible page data
01

Raw HTML availability

Check whether the fields you need are already present in the first HTML response.

Best first test for simple pages, articles, docs, listings, and product details.

Before and after JavaScript rendering comparison
02

JavaScript dependency

Compare raw HTML with the rendered DOM or screenshot before turning on browser rendering.

Use rendering when raw HTML is only a shell and scripts create the useful content.

Cookies, consent, session and access context for scraping
03

State & access context

Identify whether cookies, consent, login boundaries, pagination, or the same visitor state affect the response.

Use sessions and headers when continuity changes the data you receive.

Regional content variations across countries and routes
04

Geo/content variation

Test whether country, language, currency, inventory, SERP, ads, or route reputation changes the result.

Use geo or premium routing only when the target proves the response varies by route.

Questions before choosing parser inputs

Where is the target field?

Find whether the field exists in raw HTML, rendered DOM, an API call, structured data, a file, or a later interaction state.

What changes the response?

Sample a few URLs and compare status, final URL, content length, redirects, empty states, and visible result differences.

What context is required?

Mark any dependency on consent, locale, cookies, headers, authentication boundary, pagination, filters, or previous requests.

What does failure look like?

Define the signals for blocked, partial, stale, redirected, empty, timed-out, or region-mismatched responses before scaling.

How target behavior changes the parser request

Fetch mode

Raw HTML availability decides whether the first request can stay simple or needs rendering, waits, screenshots, or extraction.

Request context

State requirements decide whether to add headers, cookies, sessions, consent handling, or a stable visitor profile.

Routing choice

Geo and reputation findings decide whether standard routing is enough or a country/premium route is justified.

Validation rules

Known failure states become checks for retries, escalation, QA review, and deciding when a lighter profile is still complete.

Parser cost control

Keep simple parser inputs light and escalate only when markup is missing

Raw HTML is often enough for straightforward parser work. Rendering, waits, sessions, headers, screenshots, PDFs, and stronger routing belong on targets that prove they need more than source capture.

A lightweight HTML request returning a simple response
01

Basic fetch

Use a basic fetch when public HTML already contains the fields you need.

Lightest request profile; keep it when the response is complete.

JavaScript rendering producing a complete DOM
02

Rendering

Use rendering when raw HTML is a shell and JavaScript completes the page.

Heavier profile; use it only when browser output changes the result.

Several requests preserving cookies and visitor state
03

Stateful session

Use sessions when cookies, consent, locale, or pagination change the response.

Heavier state profile; preserve it only when continuity matters.

Request routing through geo and higher quality routes
04

Premium routing & geo

Use premium routing or geo only when origin, country, reputation, or regional content changes the result.

Heaviest routing profile; apply it only to targets that prove they need it.

What makes parser-ready capture heavier

More infrastructure work

Browser rendering, routing choices, and longer waits mean the platform has to do more than return a simple response.

More target uncertainty

Redirects, empty states, rate limits, and challenge pages often require stronger delivery options or retries.

More state to preserve

Cookies, sessions, consent, and multi-page flows add moving parts that a plain stateless fetch does not have.

More evidence to return

Screenshots, PDFs, rendered output, and richer response artifacts are useful, but they are heavier than plain HTML.

How to keep parsing runs predictable

Sample before scale

Test a small URL set first and group targets by the lightest profile that returns complete data.

Do not render by default

Inspect raw HTML before turning on rendering. Many public pages already contain the data you need.

Escalate by evidence

Move up only when the response shows missing content, state dependency, geo variance, or routing problems.

Measure useful results

Optimize around valid records delivered, not raw request volume. A lighter profile is best only when it stays complete.

HTML PARSER FAQ

Common questions about HTML parser API workflows

Practical answers for developers deciding how to capture, validate, and parse public page markup without making every request heavier than it needs to be.

Quick answers
BOUNDARY

What ScraperFly handles

Does ScraperFly write my parser rules?

ScraperFly captures the page source and response evidence. Your application controls selectors, extraction rules, validation, and storage.

What does format=html return?

It returns HTML from the public page request. Depending on the request profile, that can be source HTML or rendered HTML after browser execution.

RENDERING

Raw or rendered HTML

Should every parser request render JavaScript?

No. Start with raw HTML and render only when the useful DOM is missing from the source response.

How do I know raw HTML is enough?

Inspect the captured markup for the links, headings, tables, metadata, or containers your parser expects.

VALIDATION

Parser confidence

Why do selectors break after working once?

Targets can change templates, redirect, block, or render content differently. Store response evidence with parser results to separate source changes from rule bugs.

Should I use text or Markdown instead of HTML?

Use text or Markdown when readable content is the goal. Use HTML when DOM relationships, attributes, links, tables, or selectors matter.

COST

Efficient requests

How do I keep parsing affordable?

Use raw HTML for simple pages, then add rendering, waits, sessions, headers, country routing, or premium routing only when the target response proves it is needed.

Can screenshots help an HTML parser workflow?

Screenshots are useful for QA and visual proof, but they usually complement parser evidence rather than replacing HTML input.