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

Use Puppeteer Sharp to navigate to the page, wait for a signal that the content you need is ready, and then call GetContentAsync(). It returns the page’s full current HTML, including the doctype. The important part is choosing the right wait: navigation finishing does not necessarily mean a JavaScript application has rendered the data you want.

This guide shows a C# workflow for capturing that HTML, choosing between selector, JavaScript-condition, and network-idle waits, and diagnosing missing content. It also distinguishes HTML extraction from screenshots: ScreenshotNeo can capture a rendered page as an image or PDF, but it does not return the page’s HTML.

What Puppeteer Sharp returns

GetContentAsync() returns the full HTML contents of the current page, including the doctype. In practical terms, it serializes the page after the browser has processed the navigation and any JavaScript that has already changed the DOM. It is a snapshot of the document at the moment you call it—not a promise that every asynchronous widget, API response, or later update has finished.

That distinction explains many cases where a downloaded page’s original source lacks content that appears in a browser. A client-side app may add or replace DOM elements after navigation. To capture those elements, wait for a condition tied to them and only then retrieve the page content.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

If you need only a particular element’s visible text rather than the full document, query that element and read its innerText. That can be a simpler and smaller result than serializing the whole page.

Set up a Puppeteer Sharp extraction

The example below uses .NET top-level statements. Create a console project, add Puppeteer Sharp, and ensure a compatible browser is available to the library in your environment. The documentation material available for these APIs does not establish a specific package version, so check the method signatures and browser setup for the version you install.

  1. dotnet new console -n RenderedHtml
  2. cd RenderedHtml
  3. dotnet add package PuppeteerSharp
  4. Replace Program.cs with the example below, then run it with a page URL and a selector that appears when the desired content is present.

For example: dotnet run -- https://example.com "main". The example writes the captured markup to rendered.html in the current directory. Change main to a selector that represents the content you actually need; a generic page container may appear before the application has populated it.

using PuppeteerSharp;

if (args.Length < 2)
{
    Console.Error.WriteLine("Usage: RenderedHtml <url> <ready-selector>");
    return;
}

var url = args[0];
var readySelector = args[1];

using var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
    Headless = true
});

var page = await browser.NewPageAsync();
page.DefaultTimeout = 30_000;

await page.GoToAsync(url);
await page.WaitForSelectorAsync(readySelector);

var html = await page.GetContentAsync();
await File.WriteAllTextAsync("rendered.html", html);

Console.WriteLine($"Saved rendered HTML to rendered.html ({html.Length} characters).");

GoToAsync defaults to the Load navigation success condition. The selector wait is deliberately separate: it waits for the matching element to be added to the DOM, which makes the extraction depend on a page-specific readiness signal instead of navigation alone. The DefaultTimeout setting governs waits that include selector and navigation methods; the example makes that timeout explicit rather than silently allowing an indefinitely long wait.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Choose a wait that matches the content

There is no universal readiness condition for every website. Pick the condition based on what must be true before the HTML is useful.

Wait method Best fit Limitation to account for
WaitForSelectorAsync A known element appears when the required content is rendered. The element may exist before it contains usable data. Choose a selector or follow-up condition that represents readiness, not merely page structure.
WaitForFunctionAsync or WaitForExpressionAsync Readiness depends on a custom DOM or application-state condition. The expression must reflect the target site’s behavior and remain valid as its markup changes.
WaitForNetworkIdleAsync Network activity settling is a useful proxy for completion on the page. Background requests may prevent it from completing, and network quiet does not prove the required content was rendered.

Wait for an element

Use a selector when there is a stable, specific element that appears after the information of interest is available:

await page.GoToAsync(url);
await page.WaitForSelectorAsync("#results");
var html = await page.GetContentAsync();

This waits for #results to be added to the DOM. If the application inserts an empty results container first and fills it later, the selector alone may be too early; use a condition that checks the content as well.

Wait for a custom state

A truthy JavaScript expression can check a site-specific condition, such as whether a result element has children:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
await page.GoToAsync(url);
await page.WaitForFunctionAsync(
    "() => document.querySelector('#results')?.children.length > 0");
var html = await page.GetContentAsync();

This is an illustrative expression, not a universal rule. Adapt the selector and condition to the page. For example, the condition may need to check for a populated attribute, a non-empty text value, or the removal of a loading indicator. Avoid checking only that a broad container exists if it is present before rendering finishes.

Use network idle carefully

WaitForNetworkIdleAsync waits for network activity to settle. It can be useful when requests are a reasonable signal of progress, but it is indirect: an application can render after requests finish, while analytics or other background requests can keep activity going. Prefer a selector or truthy expression when you can name the content-specific condition.

There is also a documented limitation when using SetContentAsync: Networkidle0 and Networkidle2 are not supported for that method. If you are setting page content rather than navigating to a URL, use a supported wait setting or wait separately for the DOM condition you need.

Handle timeouts and extraction failures

Puppeteer Sharp’s API documentation describes DefaultTimeout as applying to waits including WaitForSelectorAsync, WaitForFunctionAsync, WaitForExpressionAsync, and navigation methods. It documents a 30-second default timeout for GoToAsync; setting a timeout to zero disables that timeout. Disabling timeouts can leave a job waiting indefinitely, so increase a limit deliberately rather than removing it as a first response.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
  • The selector times out: Confirm the selector is correct and that the expected element is actually added to the DOM. If the page uses a different route, requires interaction, or never displays that element, choose a valid readiness signal or handle that case explicitly.
  • The output is missing data: The wait may be firing on a container that appears before it is populated. Wait for a more specific selector or use a function that checks the required child count or content.
  • The page never reaches a network-idle condition: Ongoing background traffic can keep the wait from completing. Use a selector or custom state condition when available; do not treat network idle as the only definition of readiness.
  • Navigation times out: Check whether the URL loads in the browser environment and whether the navigation is slower than the configured limit. The documented navigation default is 30 seconds; choose a longer timeout only when the page’s expected behavior warrants it.
  • The saved document appears stale: Make sure GetContentAsync() runs after the relevant wait and after any action that triggers rendering. It returns the page HTML when called, not a continuously updating file.

When investigating an issue, log the URL, the condition being awaited, and which stage failed: navigation, readiness wait, or content retrieval. Those are distinct operations, and separating them makes it easier to tell a slow load from a wrong selector or an incorrect assumption about the app’s state.

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

Keep extraction reliable and appropriately scoped

A content-specific wait is usually both more meaningful and easier to diagnose than an arbitrary delay. A fixed sleep only guarantees that a chosen amount of time passed; it does not establish that the required DOM state exists. A selector or function condition encodes what the extraction needs, though it can still fail if the site changes its markup.

Use the smallest useful readiness condition, and avoid waiting on unrelated page regions. If the task only needs text from one result element, querying that element and reading its innerText can avoid saving a large full-page document. If the task needs the complete current markup, call GetContentAsync() after readiness and save or process the returned string.

Timeouts involve a trade-off: a short limit may fail on slow but valid loads; a long limit makes failures take longer to surface; zero can wait without a limit. Set the value based on how long the workflow can reasonably wait and make failure visible to the caller. The sample’s 30-second setting is an explicit example, not a guarantee that every site will finish within that time.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Or skip the browser setup

If your actual goal is a screenshot or PDF rather than HTML, ScreenshotNeo provides a website screenshot API. Its response is an image or PDF—not rendered HTML—so it is not a replacement for GetContentAsync() when you need markup. One GET request can return a screenshot; see the ScreenshotNeo API documentation for options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.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, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month without a card.

Frequently asked questions

Does Puppeteer Sharp return the original response source?

GetContentAsync() returns the full HTML contents of the current page, including the doctype. Call it after the page reaches the state you need to capture the current markup.

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

Can I use ScreenshotNeo to retrieve rendered HTML?

No. ScreenshotNeo returns a screenshot or PDF. Use Puppeteer Sharp’s page-content method when the desired output is 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.