Use puppeteer-core to connect Puppeteer to Browserless’s hosted Chromium, navigate to a page, and save the result with page.screenshot(). You need a Browserless API token and the WebSocket endpoint for your region. Close the browser connection in a finally block so the remote session does not linger.
Connect Puppeteer to Browserless
Because Browserless runs Chromium remotely, install puppeteer-core rather than the full puppeteer package. The full package downloads a local Chromium binary during installation, which this workflow does not need. Browserless’s current walkthrough uses puppeteer-core and puppeteer.connect() to attach to its hosted browser (Browserless Puppeteer connection guide).
As an Amazon Associate I earn from qualifying purchases.
- Install the package with
npm install puppeteer-core. - Get an API token from your Browserless account dashboard.
- Set the token in an environment variable named
BROWSERLESS_TOKEN; do not commit it to source control. - Use the WebSocket endpoint for your Browserless deployment and region. The SFO production hostname below is the endpoint shown in the official example, not a universal hostname.
Save this as screenshot.mjs and run it with Node.js:
import puppeteer from 'puppeteer-core';
const TOKEN = process.env.BROWSERLESS_TOKEN;
if (!TOKEN) throw new Error('Set BROWSERLESS_TOKEN before running this script.');
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://production-sfo.browserless.io?token=${TOKEN}`,
});
try {
const page = await browser.newPage();
await page.goto('https://example.com/', { waitUntil: 'networkidle2' });
await page.screenshot({ path: 'screenshot.png', fullPage: true });
} finally {
await browser.close();
}
For example, on a POSIX shell, run BROWSERLESS_TOKEN=your_token node screenshot.mjs. On other shells, set the environment variable using that shell’s syntax before running the script. The token-in-query-string pattern and page workflow follow Browserless’s documented connection approach (connection guide; screenshot walkthrough).
#1 Best Overall
Why the cleanup matters
browser.close() ends the remote session. If the script exits without closing the connection, the session can remain active until timeout and may incur billed session time, according to Browserless’s connection guide (Browserless connection guide). Keeping the cleanup in finally ensures it runs even if navigation or capture throws an error.
Choose Puppeteer or Browserless’s REST screenshot endpoint
| Workflow | Use it when | How it handles the capture |
|---|---|---|
| Puppeteer WebSocket connection | You need page interaction, selectors, custom waits, or several operations in one browser session. | Connect to the remote browser, control the page with Puppeteer, and save the screenshot with page.screenshot(). |
Browserless /screenshot REST endpoint |
You need one screenshot without custom interaction or a continuing browser session. | Send a POST request with a URL or raw HTML, an API token, and screenshot options; save the returned image bytes. |
Browserless describes the WebSocket approach as connecting existing Puppeteer code to a managed browser. Since the remote browser starts before your script connects, startup options belong in the connection URL; array-valued Chrome arguments use the encoded launch parameter (connection guide; launch options). For a one-shot REST capture, Browserless documents the /screenshot endpoint and returns image bytes (screenshot endpoint; REST API guide).
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Configure the screenshot and wait for the page
With Puppeteer, common page.screenshot() options include path, fullPage, type, quality, and clip. Use fullPage: true for content beyond the current viewport. Quality is relevant to lossy formats such as JPEG or WebP, not PNG. Browserless’s REST screenshot options support PNG, JPEG, WebP, full-page capture, quality, clip regions, viewport-related settings, and selector-based capture (Browserless screenshot API; screenshot option reference).
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesWait for content that loads late
The example uses waitUntil: 'networkidle2' for navigation, but a page’s network activity is not always a reliable signal that every visual element is ready. If the page renders a specific component after navigation, wait for that selector before capturing:
Rank #3
await page.goto('https://example.com/', { waitUntil: 'domcontentloaded' });
await page.waitForSelector('.report-ready', { timeout: 15000 });
await page.screenshot({ path: 'report.png', fullPage: true });
Replace .report-ready with a selector that appears only when the desired content is present. For pages that load images or other content on scroll, scroll through the page before capturing; Browserless’s REST API also offers a scrollPage request setting to trigger lazy-loaded content. Pair scrolling with full-page capture when the page is long (screenshot API; screenshot walkthrough).
Use REST options for a one-shot PNG
A REST request puts capture settings in an options object. This example shows the request body shape for a full-page PNG; follow Browserless’s current authentication instructions for the token when sending the POST request.
Rank #4
- 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
{
"url": "https://example.com/",
"options": {
"fullPage": true,
"type": "png"
}
}
Use this route when a single request is enough and you do not need to run page interactions between navigation and capture (screenshot endpoint; REST API guide).
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Troubleshoot incomplete or failed captures
- Connection fails: Check that
BROWSERLESS_TOKENis set and valid, and that the WebSocket hostname matches the endpoint for your deployment and region. Do not assume the SFO example endpoint applies to every account. - The job finishes but no screenshot file appears: Confirm the output path is writable and that the script reached
page.screenshot(). Inspect navigation and capture errors rather than swallowing exceptions. - The screenshot misses late content: Wait for a page-specific selector or suitable condition before capture. For lazy-loaded sections, scroll to trigger loading, then take a full-page screenshot.
- The image is blank, shows a CAPTCHA, or says access denied: Browserless identifies bot detection as a likely reason. Its separate
/unblockendpoint can handle some anti-bot cases and can return a screenshot when configured to do so, but it is not a guarantee for every protected site (screenshot documentation; unblock endpoint). - Remote sessions appear to remain active: Ensure
browser.close()runs in afinallyblock; an unclosed connection may remain active until timeout and may incur billed session time (connection guide).
Use ScreenshotNeo when you do not need a remote Puppeteer session
If you only need a screenshot from a URL and do not need Browserless-hosted Chromium or page-level Puppeteer interaction, ScreenshotNeo offers a one-request screenshot API. Its clean-capture steps can accept cookie and consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets; those steps can be turned off. Bot checks and failed captures are not billed, and an MCP server provides screenshot tools for AI agents. See the ScreenshotNeo API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/ -o shot.webp
ScreenshotNeo returns an image or PDF from one GET request; its pricing includes 1,000 shots per month on the free plan with no card, and paid plans start at $5 for 3,000 shots. Sign up free for 1,000 screenshots a month with no card.
Best Value
Frequently Asked Questions
Does Browserless run the browser on my machine?
No. In this workflow Browserless hosts Chromium and Puppeteer connects to it remotely over a WebSocket.
Can I use the full Puppeteer package instead of puppeteer-core?
You can, but the full package downloads a local Chromium binary during installation; puppeteer-core avoids that unnecessary download for a remote-browser connection.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Quick Recap
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.




