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.

Use PhantomJS’s documented page.title property, sanitize the returned text, append an image extension, and pass that path to page.render(). Read the title only after page.open() reports success; if the application changes its title after navigation, wait for its own ready signal first.

The complete script below replaces characters that are unsafe in file paths, removes trailing spaces and periods, supplies an untitled fallback, and saves a PNG named from the document title.

Complete PhantomJS script

var page = require('webpage').create();
var system = require('system');

function safeFilename(title) {
  title = (title || 'untitled').replace(/[\/:*?"<>|]/g, '_');
  title = title.replace(/[\s.]+$/g, '');
  return (title || 'untitled') + '.png';
}

var url = system.args[1];
if (!url) {
  console.log('Usage: phantomjs title-shot.js https://example.com');
  phantom.exit(2);
}

page.open(url, function (status) {
  if (status !== 'success') {
    console.log('Unable to load ' + url);
    phantom.exit(1);
    return;
  }

  var filename = safeFilename(page.title);
  page.render(filename);
  console.log('Rendered ' + filename);
  phantom.exit();
});

Save it as title-shot.js, then run:

phantomjs title-shot.js https://example.com

If the page title is Example Domain, PhantomJS writes Example Domain.png in the process’s current directory. Supply an absolute or otherwise deliberate output directory when your pipeline must keep captures in a particular location.

Why page.title is the right property

PhantomJS exposes the loaded document title as page.title. It is simpler than entering the page’s JavaScript context and is available from the PhantomJS script after navigation succeeds. You can also retrieve the same value with a sandboxed evaluation:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
var title = page.evaluate(function () {
  return document.title;
});

Use page.evaluate(function () { return document.title; }) when you already need page-context logic or want to combine title retrieval with other DOM checks. For a straightforward filename, page.title avoids an unnecessary context switch.

What the filename sanitizer must handle

A title is external input, not a trusted path. A real site can return an empty title, include characters that have special meaning to the operating system, end in spaces or periods, or be long enough to exceed a filesystem limit. It can also produce two identical titles, causing one capture to overwrite another.

Forbidden path characters

The example changes backslash, slash, colon, asterisk, question mark, quotation mark, angle brackets, and the vertical bar to underscores. Slashes are especially important: without replacement, a title such as Docs/API can be interpreted as a directory path rather than one filename.

Empty and trailing text

(title || 'untitled') covers a missing or empty title. The second replacement removes trailing whitespace and periods, which are problematic on some platforms. If that leaves an empty string, the function returns untitled.png.

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

Length, reserved names, and collisions

For production use, add a policy for maximum filename length, platform-reserved names, and duplicate titles. A practical approach is to retain a readable prefix, append a short counter or hash, and create the output directory before rendering. The exact limit depends on the filesystem and path length, so do not assume one universal number.

function uniqueName(title, index) {
  var base = safeFilename(title).replace(/.png$/, '');
  var suffix = index ? '-' + index : '';
  return base.slice(0, 180 - suffix.length) + suffix + '.png';
}

Use a counter when processing a known list, or include a stable identifier such as a URL-derived hash when jobs can run concurrently. Keeping the collision policy outside safeFilename makes the sanitization function predictable.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Navigation and readiness: when to read the title

page.open(url, callback) invokes its callback with success or fail. Render only in the success branch. A successful navigation means PhantomJS completed the navigation request; it does not guarantee that a single-page application has finished changing its DOM or title.

Titles set during initial HTML

For traditional pages, the callback is usually sufficient. Read page.title, build the filename, and call page.render() immediately.

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

Titles set by application JavaScript

If a framework changes document.title after data arrives, wait for a condition that belongs to that application. You can poll for a non-empty title, a known element, or a page-specific readiness flag, then render:

page.open(url, function (status) {
  if (status !== 'success') {
    phantom.exit(1);
    return;
  }

  var deadline = Date.now() + 10000;
  var timer = setInterval(function () {
    var ready = page.evaluate(function () {
      return document.title && document.querySelector('[data-page-ready]');
    });

    if (ready || Date.now() > deadline) {
      clearInterval(timer);
      var filename = safeFilename(page.title);
      page.render(filename);
      phantom.exit(0);
    }
  }, 100);
});

Replace [data-page-ready] with a selector your site actually sets. A timeout is important: a missing selector should produce a controlled capture or an explicit failure, not a process that waits forever.

Choosing the output format and path

page.render(filename) accepts the output filename. The extension determines the common image format, so appending .png gives you a PNG capture. If your workflow needs another supported format, change both the extension and your downstream expectations. Keep the title-derived stem separate from the extension so sanitization cannot accidentally remove or alter it.

Relative paths are resolved from the directory in which PhantomJS starts, not necessarily the directory containing the script. Use a known working directory or an absolute path when an automated job must find the output reliably.

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.
Rank #3
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Common failures and fixes

“Unable to load” is printed

The callback status was not success. Check the URL, DNS, TLS compatibility, redirects, and network access from the machine running PhantomJS. Do not call page.render() in this branch; there may be no usable page.

The output name contains folders or cannot be created

The title contained a slash or backslash, or the destination directory does not exist. Keep the replacement expression in safeFilename(), create the directory before running PhantomJS, and prefer an absolute destination for scheduled jobs.

The file is named untitled.png

The document title was empty, missing, or reduced to nothing after trimming trailing characters. Confirm that the page includes a <title> element and, for client-rendered applications, wait until the title is assigned.

The screenshot has the old title

Navigation succeeded before the application finished updating document.title. Add a readiness wait based on a real selector, flag, or other application signal. A fixed delay can help on a controlled site but is less reliable than a condition.

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

Two pages overwrite each other

Titles are not guaranteed to be unique. Add a sequence number, URL hash, or another stable identifier to the sanitized stem before calling page.render().

The process hangs

An open page, timer, or callback can keep PhantomJS alive. Clear polling timers, call phantom.exit() on every terminal branch, and set a maximum readiness wait.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

The title contains unusual Unicode

Unicode is valid in many modern filesystems, but the shell, operating system, or downstream storage may impose restrictions. Decide whether to preserve Unicode or normalize it, and test the chosen policy on every target platform. The sanitizer shown here changes only the listed path characters.

Scaling the pattern for multiple URLs

For a small batch, process one URL at a time and include an index in the output name. Sequential processing keeps memory and browser state predictable:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
var urls = [
  'https://example.com/one',
  'https://example.com/two'
];
var index = 0;

function next() {
  if (index >= urls.length) {
    phantom.exit(0);
    return;
  }

  var url = urls[index];
  page.open(url, function (status) {
    if (status !== 'success') {
      console.log('Failed: ' + url);
      index++;
      next();
      return;
    }

    var stem = safeFilename(page.title).replace(/.png$/, '');
    page.render(stem + '-' + index + '.png');
    index++;
    next();
  });
}

next();

For large batches, add logging, retry rules, a collision policy, and per-page timeouts. Keep the URL alongside the generated filename in a manifest so a title change does not make the result impossible to trace.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API when you want a clean capture without maintaining PhantomJS. A single request returns an image or PDF; you can still derive your own filename from the page title if your application first calls a metadata endpoint, or use a URL-based naming policy in your job.

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)
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}`);

See the ScreenshotNeo documentation for request options and response handling. Before capture, it can accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed as clean shots, and response headers identify the page verdict and billing state.

It also includes an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. Every plan includes the features; the free plan provides 1,000 screenshots per month without a card, and paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to try it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Operational checklist

  • Pass the target URL as a command-line argument and validate that it exists.
  • Gate all rendering on status === 'success'.
  • Read page.title after the page is ready, not merely after navigation, when JavaScript changes the title.
  • Replace path separators and forbidden characters.
  • Handle empty titles, trailing spaces or periods, excessive length, reserved names, and collisions.
  • Choose an explicit output directory and image extension.
  • Log the URL, final filename, status, and any fallback used.
  • Close timers and call phantom.exit() on success and failure.

FAQ

Can I replace rendermulti-1.png directly with the title?

Yes. Set a sanitized title-based string and pass it to page.render(); do not pass the raw title.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Is page.evaluate() required?

No. It is an alternative for page-context code; page.title is the simpler API for this task.

What if two pages have the same title?

Add a deterministic suffix such as a sequence number or URL hash so each output path is unique.

Will the callback wait for every network request?

No. It reports navigation status. Applications that render or retitle asynchronously need an application-specific readiness check.

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

Frequently Asked Questions

Can I replace rendermulti-1.png directly with the title?

Yes. Set a sanitized title-based string and pass it to page.render(); do not pass the raw title.

Is page.evaluate() required?

No. It is an alternative for page-context code; page.title is the simpler API for this task.

What if two pages have the same title?

Add a deterministic suffix such as a sequence number or URL hash so each output path is unique.

Will the callback wait for every network request?

No. It reports navigation status. Applications that render or retitle asynchronously need an application-specific readiness check.

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

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.