To capture several websites with PhantomJS, put their URLs in an array, open each URL in turn with page.open(), check its load status, and call page.render() with a unique filename. Run the JavaScript file with phantomjs multi-capture.js. Set page.viewportSize for a consistent browser viewport; use page.clipRect if you only need part of the page. PhantomJS is now a legacy option: its development is suspended, so test the exact binary against your target sites before depending on it.
Capture multiple URLs sequentially
PhantomJS does not provide a built-in batch screenshot command. The batch behavior comes from your script: keep a list of URLs, open one page at a time, render a distinct output file, then move to the next URL after the current page.open() callback completes. This makes it easier to associate a failed load with its URL and avoids concurrent callbacks writing to the same page object.
Save the following as multi-capture.js:
var page = require('webpage').create();
var targets = [
'https://example.com/',
'https://example.org/'
];
var index = 0;
page.viewportSize = { width: 1365, height: 768 };
function next() {
if (index >= targets.length) {
phantom.exit();
return;
}
var url = targets[index];
var output = 'capture-' + (index + 1) + '.png';
index += 1;
page.open(url, function (status) {
if (status === 'success') {
page.render(output);
console.log('Saved ' + output + ' from ' + url);
} else {
console.log('Failed to load ' + url + ' (' + status + ')');
}
next();
});
}
next();
Replace the example addresses with the pages you want to capture. The index produces capture-1.png, capture-2.png, and so on. For durable runs, use filenames that identify the page or a stable identifier from your input data; avoid deriving filenames directly from arbitrary URLs without sanitizing characters that may be invalid in a filename.
Run the script
From the directory containing the script, run:
phantomjs multi-capture.js
The command-line form is phantomjs [options] somescript.js. The PhantomJS command-line reference describes version 2.1.1 unless otherwise noted, so record which binary you use when reproducibility matters.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- 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.
Why the sequence matters
page.open() is asynchronous: its callback receives a status of success or fail. In this pattern, next() runs from inside that callback, so the next URL starts only after the prior open attempt has finished. phantom.exit() runs when the index reaches the end of the list. If you remove the callback check or exit too early, the script can save a failed page or terminate before the capture queue is complete.
Choose the viewport, capture region, and output format
Set a consistent browser viewport
page.viewportSize controls the browser viewport used to lay out the page. Set it before opening pages when all captures should use the same dimensions:
page.viewportSize = { width: 1365, height: 768 };
Use the same viewport for each URL when you need screenshots that are comparable across runs. A viewport is not a promise that the entire document fits in the image; a long page may extend below the visible area. Test representative pages if responsive breakpoints or site-specific layouts affect the result.
Capture only a rectangle
Set page.clipRect when you need to render a region rather than the full viewport. For example:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →page.clipRect = { top: 0, left: 0, width: 800, height: 600 };
Choose the rectangle to match the area you want in the output. Clipping is useful for a fixed region, but it is not a substitute for selecting a page element: changes to layout can move the content relative to those coordinates.
Rank #2
- 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.
Select a file format
page.render() selects the output format from the filename extension. The screen-capture guide lists PNG, JPEG, GIF, and PDF. Give each output an extension matching the format you want, such as .png, .jpg, .gif, or .pdf. To set JPEG quality explicitly:
page.render('capture.jpg', { format: 'jpeg', quality: 90 });
The optional render settings include format and quality. Use an image format for screenshots intended for image viewing; PDF is available where a document output is more useful. Confirm the produced file type and visual result in your own workflow, particularly when changing the extension or render options.
Handle delayed and dynamic page content
The page.open() callback tells you that PhantomJS has completed its page-open operation; it does not establish that every site-specific asynchronous widget, image, or late network response has finished rendering. If content appears after the initial load, delay the render or check a page-level readiness condition that is meaningful for that site.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Add a bounded delay
The PhantomJS homepage demonstrates inserting a short setTimeout() before rendering. A delay can be useful for pages that settle shortly after load, but there is no universal wait duration that guarantees completeness across websites. Choose a bounded value based on the page behavior you need, and verify the screenshot rather than assuming that a longer wait always fixes the problem.
To add a delay in the successful-load branch, replace the immediate render with a timer:
Rank #3
- 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.
page.open(url, function (status) {
if (status === 'success') {
window.setTimeout(function () {
page.render(output);
console.log('Saved ' + output + ' from ' + url);
next();
}, 1500);
} else {
console.log('Failed to load ' + url + ' (' + status + ')');
next();
}
});
This example waits 1.5 seconds as an implementation choice, not as a site-independent guarantee. Because the callback to next() is moved inside the timer on success, the next URL does not start until after the screenshot is rendered.
Use a readiness check where possible
If a page exposes a reliable signal that the content you care about is ready, wait for that condition and render afterward. Keep the wait bounded so a missing selector or broken page cannot stall the entire batch indefinitely. PhantomJS is old software, and modern sites may depend on browser features it does not support; a wait cannot make an unsupported feature work.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Make a batch useful and reproducible
- Keep the URL-to-file mapping clear. Log both the source URL and output name so a later review can identify which capture belongs to which target.
- Keep filenames unique. If two URLs map to the same filename, a later render may overwrite an earlier one. The sequential example avoids that by numbering outputs.
- Keep the viewport fixed. Changing viewport dimensions between runs can change responsive layout and make screenshots difficult to compare.
- Track failures separately. The example logs failed opens and continues; if missing a page should fail the whole job, collect failures and return an appropriate process status in your surrounding automation.
- Keep changing URL sets under version control or in a controlled input file. That makes it possible to reproduce which targets a batch attempted to capture.
For a small number of known URLs, a sequential queue is simple and predictable. If you later add retries, make the retry limit explicit and log each attempt; endless retries can prevent the script from reaching the end of the queue. These are script-level workflow choices, not built-in PhantomJS batch features.
Troubleshooting common problems
The command cannot find PhantomJS
If the shell reports that phantomjs is not recognized or not found, the executable is either not installed or is not available on the shell’s PATH. Confirm the binary can be invoked directly, then rerun the script using its full executable path if necessary. The exact installation steps depend on your operating system and binary source.
A URL is logged as failed
When page.open() reports fail, the script should not render that page as if it succeeded. Check that the URL is valid and reachable from the machine running PhantomJS, then try the page individually and record any network or site behavior that affects loading. Decide whether a failed target should be skipped, retried a limited number of times, or cause the batch to be marked unsuccessful.
Rank #4
- 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 screenshot is blank or incomplete
First distinguish a load failure from a successful but visually incomplete render by inspecting the logged status and opening the output file. If the page loads successfully but content arrives later, add a bounded delay or a page readiness check. If the target relies on newer browser behavior unavailable in PhantomJS, timing changes may not solve it; test the target directly and consider a maintained browser automation stack for new work.
Only part of the page appears
Check both the viewport and page.clipRect. The viewport determines the browser’s layout area, while the clip rectangle limits the rendered region. A restrictive clip can hide content even when it has loaded. Remove or adjust clipping and test again at the intended viewport size.
Captures overwrite one another
Make the output filename unique for every URL. A fixed name such as capture.png inside a loop will be reused each time. Include an incrementing index or a sanitized page identifier, and ensure repeated runs write to the expected directory.
Output format or quality is unexpected
Check that the output extension matches the desired format because PhantomJS chooses a format from the filename extension. For JPEG, use the documented render options if you need to specify quality. Open the resulting file with an appropriate viewer and validate the format and visual output before using the batch in production.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Understand PhantomJS’s maintenance status
PhantomJS is a command-line, scriptable headless browser, but it is a legacy choice rather than a maintained foundation for new browser automation. Its project homepage states, “Important: PhantomJS development is suspended until further notice.” The project wiki describes the 2.x branch as deprecated and no longer maintained, and the GitHub repository is archived. Those status statements matter because website browser requirements change: validate the exact PhantomJS binary against every important target instead of assuming current sites will behave as they did when the software was maintained.
Recommended Free Tools
Best Value
- 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.
For an existing script that still meets its needs, document the binary version, operating environment, viewport, output settings, and target URLs. For a new system, weigh maintenance status and browser compatibility alongside screenshot format support, clipping controls, dynamic-content handling, batch orchestration, and whether execution must be local or hosted. The status information alone does not identify a particular replacement as suitable for every project.
Or skip the browser setup
If your goal is to capture URLs rather than maintain a PhantomJS runtime, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns an image or PDF. Before a capture, it accepts cookie or consent banners like a visitor 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 cost nothing, and response headers report the page verdict and whether the request was billed.
For example, this cURL request saves a WebP screenshot of a target URL (replace the URL and API key):
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. The API supports PNG, JPEG, WebP, and PDF output, along with full-page capture, CSS-selector element capture, viewport and device settings, custom CSS and JavaScript, wait conditions, request blocking, headers and cookies, caching, asynchronous jobs, bulk capture, and other controls. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteScreenshotNeo has a free plan for 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo free to start with 1,000 screenshots a month and no card required.
Frequently Asked Questions
Can PhantomJS capture a list of URLs in parallel?
The example here processes URLs sequentially with one page object. Parallel capture requires a different orchestration design and should not be assumed to be a built-in batch mode.
Does a successful page.open status guarantee every image has loaded?
No. It reports the open status, not a universal readiness guarantee for all site-specific dynamic content.
What version does the PhantomJS command-line documentation cover?
The command-line reference says it applies to PhantomJS 2.1.1 unless otherwise noted.
Quick 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.

