What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use page.url() to read the page’s current address, convert its hostname and pathname into a safe filename, then pass the resulting path to page.screenshot(). The example below also adds a short hash of the full URL so pages with different query strings or fragments do not overwrite each other.
Save a screenshot using the current page URL
This runnable JavaScript example uses Playwright’s Chromium browser. It creates a screenshots directory, sanitizes the readable part of the address, limits its length, and adds a SHA-256 hash for distinction between URLs that share a hostname and pathname.
As an Amazon Associate I earn from qualifying purchases.
import { createHash } from 'node:crypto';
import { mkdir } from 'node:fs/promises';
import path from 'node:path';
import { chromium } from 'playwright';
function filenameFromUrl(rawUrl) {
const url = new URL(rawUrl);
// Keep the readable part short and avoid path separators and punctuation.
const readable = `${url.hostname}${url.pathname}`
.replace(/[^a-zA-Z0-9._-]+/g, '-')
.replace(/^-+|-+$/g, '')
.slice(0, 100) || 'page';
// Hash the full URL so pages differing by query or fragment do not overwrite.
const hash = createHash('sha256').update(rawUrl).digest('hex').slice(0, 10);
return `${readable}-${hash}.png`;
}
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com/products?id=42');
const outputDir = path.resolve('screenshots');
await mkdir(outputDir, { recursive: true });
const outputPath = path.join(outputDir, filenameFromUrl(page.url()));
await page.screenshot({ path: outputPath, fullPage: true });
console.log(`Saved screenshot to ${outputPath}`);
} finally {
await browser.close();
}
Install Playwright and its browser binaries before running the script. The path is resolved from the process’s current working directory; the resulting image is a full-page PNG. Remove fullPage: true to capture only the viewport. Playwright documents page.url() and the screenshot path option in its Page API.
Choose a filename policy deliberately
Readable name and safety
The hostname and pathname make the file recognizable, while replacing characters outside letters, numbers, dots, underscores, and hyphens avoids path separators and many problematic filename characters. The 100-character cap keeps the readable component bounded. URL-to-filename conversion is application logic; Playwright accepts the path but does not prescribe a naming scheme.
#1 Best Overall
- Get NVMe solid state performance with up to 1050MB/s read and 1000MB/s write speeds in a portable, high-capacity drive(1) (Based on internal testing; performance may be lower depending on host device & other factors. 1MB=1,000,000 bytes.)
- Up to 3-meter drop protection and IP65 water and dust resistance mean this tough drive can take a beating(3) (Previously rated for 2-meter drop protection and IP55 rating. Now qualified for the higher, stated specs.)
- Use the handy carabiner loop to secure it to your belt loop or backpack for extra peace of mind.
- Help keep private content private with the included password protection featuring 256‐bit AES hardware encryption.(3)
- Easily manage files and automatically free up space with the SanDisk Memory Zone app.(5). Non-Operating Temperature -20°C to 85°C
Queries, fragments, and collisions
The example hashes the entire URL, including its query string and fragment, without exposing those values in the visible filename. This helps distinguish URLs such as /products?id=42 and /products?id=43. If query parameters are only tracking values and should not produce separate files, normalize the URL or hash only the parts that define the page state. That makes names more stable, but URLs treated as equivalent can then map to the same filename. A hash reduces accidental collisions; it is not a guarantee that two distinct URLs can never share a name.
Sensitive URL values
Do not put raw query strings into filenames without considering privacy: they can contain search terms, identifiers, or tokens. A hash avoids displaying those values, but the original URL may still be present in logs or other parts of your workflow. Avoid capturing or persisting sensitive page state unless your handling and storage are appropriate for it.
Rank #2
- Solid state performance with up to 800MB/s read speeds in a portable drive. (Based on internal testing; performance may be lower depending on host device, interface, usage conditions and other factors. 1MB=1,000,000 bytes.)
- Back up your content and memories on a storage solution that fits seamlessly into your mobile lifestyle.
- Take it with you on your adventures—up to two-meter drop protection means this durable drive can take a beating. (Based on internal testing.)
- Secure it to your belt loop or backpack for extra peace of mind thanks to the tough rubber hook.
- From Sandisk, a brand professional photographers trust to take on assignments.
Capture options and alternative output
- Viewport screenshot: call
page.screenshot({ path: outputPath })withoutfullPage. - Full page: set
fullPage: true, as in the example. Full-page capture can produce a much taller image than the viewport. - Image buffer: omit
pathandpage.screenshot()returns image data that your script can upload or process. The official screenshot guide shows the screenshot workflow.
If the screenshot will be used in a Playwright Test assertion, test.info().snapshotPath(name, { kind: 'screenshot' }) supplies a path based on the configured snapshot layout. For a custom name derived from the live page URL, generate the path yourself and pass it to page.screenshot(); a test snapshot path serves a different purpose. See the TestInfo API.
PC 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 & 11Outdated 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 matchOr skip the browser setup
ScreenshotNeo can return a screenshot from one GET request, without running Playwright in your project. The endpoint accepts a URL and returns an image or PDF. See the ScreenshotNeo API documentation for request options.
Rank #3
- Capacity Display Variance: 500GB external ssd often appears as around 465GB on Windows. MacOS can show full 500 GB capacity. This is binary calculation difference and doesn’t affect SSD hard drive actual physical storage
- 1050 MB/s Speed: Instantly access to your files with blazing-fast 10Gbps external SSD read up to 1050MB/s and write up to 1000MB/s. LED Light indicates USB SSD instant activity
- Data Security: Solid state drives S.M.A.R.T. health diagnostics and adaptive TRIM optimizing data block management ensures consistent write speeds and extends the longevity of the portable SSD
- USB-C & USB-A Cable: Both cables featuring rapid USB 3.2 Gen2, this USB SSD effortlessly bridges devices, enabling seamless cross-platform file transfers and backup between computers, smartphones, tablets and iPhone
- Always Fast: No slowdowns for large file transfers. With SLC caching (25% of current available capacity allocated as high-speed cache), this external SSD delivers steady 10Gbps for transfers within the cache capacity
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/products?id=42 -o shot.webp
ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Visit ScreenshotNeo or sign up free to try 1,000 screenshots a month with no card.
Troubleshooting
The screenshot is saved somewhere unexpected
Relative paths are resolved from the current working directory. This example uses path.resolve('screenshots') and prints the absolute output path; check that path rather than assuming the script file’s directory is the working directory.
Different pages overwrite each other
Check whether your filename function includes the URL components that distinguish the pages. The sample hashes the full URL. If you changed it to hash only the pathname, pages with different query values may intentionally share a filename.
Rank #4
- NEARLY 2X FASTER THAN OUR PREVIOUS GENERATION(8) – move 1,000 high-res photos in under 60 seconds(6) with up to 2000MB/s transfer speeds(2).
- IP65 RATING AND UP TO 3M DROP PROTECTION(3) – protects against spills and drops.
- POCKET-SIZED – fits easily in pockets and small bags.
- SPACE TO OWN YOUR AI CONTENT – speed and capacity to download your high-res clips and photo edits.
- 256-BIT AES ENCRYPTION(4) – helps keep private files secure with password protection.
The filename is too long or contains awkward characters
Keep a bounded readable component and replace unsafe characters before joining it to the output directory. Do not use an unsanitized URL as a path: slashes can create unintended nested paths, and long query values can make filenames unwieldy.
The capture fails before a file is written
Confirm Playwright and the selected browser are installed, that page.goto() reaches the intended URL, and that the process can write to the output directory. The example creates the directory recursively; it cannot grant filesystem permissions the process does not have.
Best Value
- Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
The screenshot contains only part of the page
By default, the capture is the viewport. Set fullPage: true for a full-page screenshot, and ensure the page has loaded the content you expect before taking it.
Frequently Asked Questions
Does Playwright automatically use the page URL as the screenshot filename?
No. Read the URL and construct a path in your script, then provide it with the screenshot call’s path option.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Does the example include query values in the filename?
No. It incorporates the full URL through a hash, while the readable filename contains only the hostname and pathname.
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.




