Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To get HTML after a page’s JavaScript has run, open the URL in a browser and serialize the resulting document. With Playwright, call page.goto(), wait for the page-specific content you need, then use page.content(). If you only need a few values, extract those with selectors instead of transferring the whole document. For a managed browser request, Browserless offers a Content API that returns rendered HTML. None of these approaches guarantees success on every URL: access, authentication, bot defenses, network conditions, and the page’s own readiness behavior matter.

What “rendered HTML” means

A direct HTTP request typically gives you the response body sent by the server. A browser can then parse that document, run JavaScript, and update the DOM. The HTML you serialize after those changes is often called rendered HTML. It may differ substantially from the original response.

Rendered HTML is a snapshot of the browser document at a particular moment, not proof that every asynchronous widget, lazy-loaded section, or interaction has completed. Decide which content must be present, then wait for a condition that represents that content. Playwright’s page.content() returns the full HTML contents of the page, including the doctype; it does not decide whether the page is ready for your purpose. Playwright Page API

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the right method

Method Use it when What you get Main trade-off
Direct HTTP fetch The response already contains the markup or data you need. The server’s response body, without browser-side JavaScript execution. It will not reproduce client-side DOM changes.
Playwright You need browser execution, custom waits, or control over navigation. The document state exposed by a browser after navigation and any waits you add. You manage browser installation, lifecycle, and page-specific synchronization.
Browserless Content API You want a hosted, one-request browser workflow. Rendered HTML returned as text/html. Requires an account token and depends on the service’s endpoint limits and access rules.
Selector-based extraction You only need a few fields rather than a complete document. Selected values extracted from a rendered DOM. You need selectors that match the target page’s structure.

Browserless documents distinct /content and /scrape endpoints, plus Smart Scrape, which it describes as an HTTP-first approach that can fall back to a browser for JavaScript-rendered pages. These are method options, not a guarantee about how any particular URL behaves. Browserless REST APIs

Get rendered HTML with Playwright

Install Playwright

In a Node.js project, install Playwright using your package manager, then install its browser binaries as described in the Playwright installation guide. The script below uses the documented chromium browser API. It is an implementation example, not a tested result for a particular site.

import { chromium } from 'playwright';

const url = 'https://example.com/';
const browser = await chromium.launch();

try {
  const page = await browser.newPage();
  const response = await page.goto(url);

  // Replace this with a selector that identifies the content you need.
  // For example: await page.locator('main article').waitFor();

  const html = await page.content();
  console.log({ status: response?.status(), html });
} finally {
  await browser.close();
}

For a reusable script, write the HTML to a file rather than printing a potentially large document to the terminal. For example, add import { writeFile } from 'node:fs/promises'; and replace the console.log call with await writeFile('page.html', html, 'utf8');.

Wait for the content you actually need

A call to page.goto() handles navigation; it cannot know when a site-specific result, product list, or article body is complete. Prefer a selector or state tied to the content over an arbitrary fixed sleep. For example, if the page’s main article is identified by article, wait for it before serialization:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
await page.locator('article').waitFor();
const html = await page.content();

Choose a selector that exists on the target page and represents useful content. A generic container may appear before its text has loaded, while a selector for a specific result can be more meaningful. If content is revealed only after a click or scroll, perform that interaction before calling page.content(). The necessary readiness condition varies by site; there is no single wait setting that guarantees all pages are finished.

Check the navigation response

Navigation completing is not the same as the server returning HTTP 200. Playwright documents that valid HTTP error statuses such as 404 and 500 do not, by themselves, make page.goto() throw. Inspect the returned response when status matters, and handle a missing response when navigation does not produce one. Playwright Page API

When a direct HTTP request is enough

If the content you need is present in the initial response, a normal HTTP fetch is simpler and avoids launching a browser. This is a decision to make by inspecting the response or testing the site’s documented interface; the title “any URL” does not mean every page needs or supports browser rendering.

Use a browser when client-side scripts create or materially change the target content. If the initial response has a shell with little useful text and the browser later fills in the page, an HTTP-only fetch will not return that later DOM. Browserless describes Smart Scrape as an HTTP-first cascade with browser fallback for pages that need JavaScript rendering. Browserless REST APIs

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Browserless to request rendered HTML

Browserless’s Content API accepts a URL in a JSON request, requires a token, and returns HTML as text/html. Its documented request shape is:

curl -X POST 'https://production-sfo.browserless.io/content?token=YOUR_API_TOKEN' 
  -H 'Content-Type: application/json' 
  -d '{"url":"https://example.com/"}'

Replace YOUR_API_TOKEN with a token from your Browserless account and set the JSON URL to the page you want. Avoid putting live credentials in public source code, shared logs, or command history. Browserless documents errors including authorization, forbidden destination, timeout, and rate-limit responses. Browserless Content API Browserless browser options

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Extract selected data instead of the entire page

If a downstream job needs a title, price, heading, or a handful of links, returning a full HTML document may be unnecessary. Browserless documents /scrape for CSS-selector extraction against a rendered DOM, while /content returns the full HTML. Use the smaller output when selected values satisfy the task; use full HTML when later processing genuinely needs the document. Browserless REST APIs Browserless: Scrape a website URL

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server, not a rendered-HTML extraction endpoint: it returns a screenshot or PDF rather than the page’s HTML. If a visual capture is what you need, one GET request can return an image, and the API accepts url as a query parameter. See the ScreenshotNeo website and API documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/ -o shot.webp

ScreenshotNeo accepts cookie or consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Each feature is available on every plan.

Sign up for 1,000 free screenshots a month with no card.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting rendered HTML

The HTML lacks text visible in the browser

  • Likely cause: The page was serialized before its scripts populated the relevant part of the DOM, or the content requires an interaction.
  • Fix: Wait for a selector associated with the desired content. If it appears only after a click or scroll, reproduce that interaction before calling page.content().

The page appears complete, but the status is an error

  • Likely cause: The server returned a valid HTTP error response such as 404 or 500; Playwright navigation can still complete for these statuses.
  • Fix: Inspect response?.status() and decide whether your workflow should accept, report, or reject the document.

The managed endpoint rejects the request

  • Likely cause: The token is missing or invalid, the destination is forbidden, or the request has hit a service limit.
  • Fix: Check the token and endpoint documentation, then interpret the returned HTTP error rather than treating every failure as a rendering problem. Browserless documents authorization, forbidden-destination, timeout, and rate-limit errors. Content API documentation

The result is incomplete or the request times out

  • Likely cause: The target page is slow, depends on delayed resources, or does not expose the expected content under the conditions of the request.
  • Fix: Make the readiness condition specific, inspect the response and rendered state, and distinguish an incomplete capture from an access or network failure. No documented method guarantees access to every URL; respect authentication and site access controls.

Reliability, performance, and cost considerations

A direct HTTP request avoids browser startup and is appropriate when the response already contains the needed markup. A browser adds rendering work but gives you access to client-side DOM changes and control over page interaction and waiting. A hosted API removes the need to manage a local browser process for a one-off request, but introduces a credential, service limits, and endpoint-specific errors. The available documentation does not establish universal speed, success-rate, or cost figures, so compare options using your own target pages and workload.

For repeated collection, avoid waiting longer than the task requires: wait on meaningful content rather than an arbitrary delay. Extract only the fields you use when full documents are unnecessary. Keep API credentials out of logs and public code, and treat the HTML as untrusted input if you pass it into another system.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FAQ

Does rendered HTML include the doctype?

Yes. Playwright describes page.content() as returning the full HTML contents of the page, including the doctype. Playwright Page API

Can I get rendered HTML without installing a browser locally?

Yes. Browserless documents a hosted Content API that accepts a URL and returns rendered HTML, provided you supply an account token. Browserless Content API

Does a screenshot API return rendered HTML?

Not necessarily. ScreenshotNeo returns screenshots or PDFs; use Playwright or a rendered-content API when the output must be HTML.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.