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.

To capture a website as it appears in a browser, use Perl to drive Chrome or Chromium with WWW::Mechanize::Chrome. The module connects to Chrome through the Chrome DevTools Protocol, executes page JavaScript, waits for the rendered document, and returns PNG image data. A compatible Chrome or Chromium installation is required.

The method below captures a viewport screenshot in headless mode, saves it correctly as binary data, and explains how to adapt it for full-page or element captures. If you do not want to install and supervise a browser, ScreenshotNeo provides a hosted, one-request alternative later in the guide.

What you need before writing the script

  • Perl installed and able to install CPAN modules.
  • WWW::Mechanize::Chrome installed from CPAN or your distribution repository.
  • Chrome or Chromium installed at a location the module can launch or connect to.
  • Permission to access the target site and enough disk space for the output image.

Chrome/Chromium is essential because a screenshot is a rendered visual result, not the bytes returned by an HTTP request. A plain Perl HTTP client can download HTML, but it cannot by itself reproduce CSS layout, JavaScript-generated content, fonts, or images as a browser does.

Install the Perl module and browser

Install the module with your preferred CPAN client:

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.
cpan WWW::Mechanize::Chrome

On systems using cpanm:

cpanm WWW::Mechanize::Chrome

Install Chrome or Chromium using your operating system’s normal package or vendor process. The exact executable name and path vary by operating system. If the module cannot find the browser, consult the installed version’s documentation for its browser-path and connection options rather than assuming a fixed path.

Check both prerequisites before debugging your capture script:

perl -MWWW::Mechanize::Chrome -e 'print "module OKn"'

Then verify that Chrome or Chromium starts normally. A browser that is unavailable, blocked by a sandbox, or incompatible with the installed module will fail before navigation begins.

Minimal Perl screenshot script

This is the smallest useful pattern documented for WWW::Mechanize::Chrome:

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.
use strict;
use warnings;
use WWW::Mechanize::Chrome;

my $mech = WWW::Mechanize::Chrome->new(headless => 1);
$mech->get('https://example.com');
my $png = $mech->content_as_png();

headless => 1 keeps a browser window from opening. The module documentation describes visible mode as the default, so omit that option when you need to watch the browser while diagnosing a page.

Complete runnable script that saves a PNG

Screenshot bytes must be written in binary mode. Opening the file as text can translate bytes on some platforms and corrupt the image.

#!/usr/bin/env perl
use strict;
use warnings;
use FindBin qw($Bin);
use WWW::Mechanize::Chrome;

my $url    = shift @ARGV || 'https://example.com';
my $output = shift @ARGV || "$Bin/shot.png";

my $mech = WWW::Mechanize::Chrome->new(
    headless => 1,
);

$mech->get($url);
my $png = $mech->content_as_png();

open my $fh, '>:raw', $output
    or die "Cannot open $output for writing: $!n";
print {$fh} $png
    or die "Cannot write $output: $!n";
close $fh
    or die "Cannot close $output: $!n";

print "Saved $outputn";

Run it with:

perl screenshot.pl https://example.com /tmp/example.png

The resulting file is a PNG representing the browser’s captured page state. Use an image viewer or an image-identification command to verify that the file is non-empty and has a PNG signature.

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 the screenshot scope before capturing

“A website screenshot” can mean several different outputs. Decide which one your automation should produce.

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

Viewport screenshot

The minimal script captures the browser’s current visible area. This is appropriate for a hero section, dashboard view, or a fixed-size visual regression target. The exact dimensions depend on the browser viewport and the module/browser settings you use.

Full-page screenshot

A full-page image covers the page’s scrollable content rather than only the initial viewport. Long pages can produce very tall PNGs, consume substantial memory, and expose lazy-loading behavior. The screenshot API and page-capture options available in your installed WWW::Mechanize::Chrome version determine how full-page capture is requested; verify those version-specific details in its documentation before deploying a production script.

Element screenshot

For a component such as a chart or article body, select the element with a CSS selector and capture that region if your installed module version supports element screenshots. This avoids stitching unrelated navigation and whitespace into the output. Confirm selector and element-capture method names against the version you installed.

Make dynamic pages deterministic

Navigation returning successfully does not guarantee that the visual content you want has finished rendering. JavaScript applications may populate the DOM after the initial response; images may load lazily; animations may still be moving.

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

Wait for the page state you need

Use a page-specific readiness condition when the module version exposes one, such as waiting for a selector that only appears after the application has rendered. A fixed delay can be useful for a simple page, but it is less reliable than waiting for a meaningful element.

Control animations and caret state

Browser screenshot tooling commonly disables CSS animations and controls text-caret visibility for repeatable output. Treat those as browser-automation concepts: do not assume that a Playwright option has the same name or availability in WWW::Mechanize::Chrome. If your module does not provide an equivalent, inject a small, page-approved stylesheet or capture after the animation has reached a stable state.

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.

Handle lazy-loaded content

Some pages load images only when they approach the viewport. A viewport capture may therefore omit images farther down the document, while a full-page capture may trigger additional loading. If completeness matters, scroll or otherwise exercise the page before calling content_as_png(), then wait for the required images or selectors.

Headless versus visible Chrome

Mode Use it when Trade-off
Headless Running on CI, a server, or a scheduled job No visible window; browser launch and sandbox issues can be less obvious
Visible (the documented default) Inspecting navigation, consent dialogs, layout, and failures interactively Requires a graphical session and opens a browser window

Start in visible mode when diagnosing a page that looks blank or incomplete. Once navigation and selectors are correct, switch to headless mode for unattended execution.

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

Common failures and fixes

“Chrome/Chromium was not found”

Cause: the browser is not installed, is not on the expected path, or the process lacks permission to launch it.

Fix: install a compatible browser, confirm it starts under the same user as the Perl process, and follow your installed module’s documentation for an explicit executable path or remote-debugging connection.

The script hangs during startup

Cause: a browser sandbox, profile lock, display requirement, or DevTools connection problem.

Fix: run the script visibly on a development machine, inspect the browser’s startup error, and use a dedicated temporary profile for automation. On hardened Linux environments, review the sandbox policy rather than blindly disabling security controls.

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

The output file is empty or unreadable

Cause: the file was opened in text mode, writing failed, or the navigation failed before screenshot data was returned.

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

Fix: use >:raw, check every open/write/close result, and log the URL and exception around get and content_as_png.

The screenshot shows a blank page

Cause: the application had not finished its JavaScript render, a required resource failed, or the site presented a bot check.

Fix: test visibly, wait for an application-specific selector, check browser console/network errors where available, and confirm the target permits automated access. Do not treat a bot-check screen as a successful representation of the intended page.

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

Images or fonts are missing

Cause: the capture happened before resources completed, the resources require authentication, or cross-origin/resource policy blocked them.

Fix: wait for the relevant elements, provide authorized cookies or headers only when you are entitled to do so, and capture after the page reports the resources ready.

The full-page image is too large

Cause: a long document produces a very tall raster image.

Fix: capture a viewport or selected element, split the page into sections, or use a PDF workflow when a paginated document is the actual requirement.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Firefox as an alternative Perl route

The WWW::Mechanize::Firefox distribution includes a screenshot.pl example that documents PNG output and options for output file, target width, height, and scale. Its available documentation is older, with a listing dating from roughly 2018, so verify current Firefox, module, and automation compatibility before choosing it for a new project. The evidence does not establish a current feature-by-feature winner between the Chrome and Firefox routes.

Performance, reliability, and operating costs

  • Startup cost: launching a browser for every URL is slower than reusing a controlled browser process. Reuse must be designed carefully so cookies, local storage, and page state do not leak between jobs.
  • Memory: full-page and high-resolution captures require more memory than viewport images. Limit concurrency and dispose of pages or browser instances according to your module version’s lifecycle guidance.
  • Repeatability: record the URL, viewport, browser version, module version, and capture timestamp. Dynamic ads, animations, personalization, and changing data can alter pixels without code changes.
  • Security: treat target URLs as untrusted input. Restrict outbound access, avoid exposing internal network services, and do not pass secrets to pages unless the capture is authorized.
  • Cost: a local Perl/browser workflow has no per-image hosted API charge, but you operate the browser, machine, updates, retries, and monitoring yourself.

Or skip the browser setup

ScreenshotNeo is a hosted website screenshot API and MCP server. It accepts one GET request and returns PNG, JPEG, WebP, or PDF output. Before capture it accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.

For Perl, call the API with any HTTP client:

use strict;
use warnings;
use LWP::UserAgent;

my $ua = LWP::UserAgent->new(timeout => 90);
my $response = $ua->get(
  'https://api.screenshotneo.com/v1/shot',
  { access_key => 'YOUR_API_KEY', url => 'https://stripe.com' }
);
die $response->status_line unless $response->is_success;
open my $fh, '>:raw', 'shot.webp' or die $!;
print {$fh} $response->content;
close $fh;

See the ScreenshotNeo documentation for all 63 options, including full-page and selector captures, device presets, retina scale, custom CSS and JavaScript, click actions, waits, blocked resources, headers, cookies, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage data, and the OpenAPI specification. Existing parameter names used by other screenshot APIs also work, easing migration.

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing provides two months free. Create a free ScreenshotNeo account to begin.

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

Equivalent API examples for other scripts

cURL

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

Frequently Asked Questions

Can Perl capture a page that requires JavaScript?

Yes. A Chrome/Chromium automation module executes the page in a real browser, so JavaScript-created content can be rendered before the PNG is requested.

Should I use PNG, JPEG, or PDF?

Use PNG when lossless UI detail matters, JPEG for smaller photographic images, and PDF when the desired result is a paginated document rather than a single raster image.

Is a full-page screenshot the same as a viewport screenshot?

No. A viewport image covers the visible browser area; a full-page image covers the document’s scrollable content and can be substantially taller.

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.