Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
browser automation

How to Take Bulk Screenshots with Playwright in Go

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.

For a batch of URLs, start Playwright and Chromium once, reuse a page, navigate to each URL, and save each capture to a unique filename with Page.Screenshot. Set FullPage when you need the whole scrollable document; otherwise the capture is limited to the visible viewport. The Go examples below show a sequential workflow, per-URL error handling, full-page and element captures, and practical choices for readiness, output format, and scale.

Set up a bulk capture loop

This example uses the playwright-go package. It launches one Playwright process and one Chromium browser, then reuses a page for every URL. The zero-padded index makes the output paths distinct and preserves the input order.

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/playwright-community/playwright-go"
)

func main() {
	urls := []string{
		"https://example.com/one",
		"https://example.com/two",
	}

	if err := os.MkdirAll("screenshots", 0755); err != nil {
		log.Fatal(err)
	}

	pw, err := playwright.Run()
	if err != nil {
		log.Fatal(err)
	}
	defer pw.Stop()

	browser, err := pw.Chromium.Launch()
	if err != nil {
		log.Fatal(err)
	}
	defer browser.Close()

	page, err := browser.NewPage()
	if err != nil {
		log.Fatal(err)
	}

	for i, url := range urls {
		if _, err := page.Goto(url, playwright.PageGotoOptions{
			WaitUntil: playwright.WaitUntilStateDomcontentloaded,
		}); err != nil {
			log.Printf("navigation failed for %s: %v", url, err)
			continue
		}

		path := fmt.Sprintf("screenshots/page-%04d.png", i+1)
		if _, err := page.Screenshot(playwright.PageScreenshotOptions{
			Path:     playwright.String(path),
			FullPage: playwright.Bool(true),
		}); err != nil {
			log.Printf("screenshot failed for %s: %v", url, err)
		}
	}
}

Save this as a Go file in a project that has github.com/playwright-community/playwright-go available, then run it with go run. Playwright also needs its browser installation available in the environment; follow the package’s setup instructions for the version you install. The API calls shown here follow the documented Go example and package reference: Playwright screenshot guide and playwright-go.

Understand the loop’s lifecycle

playwright.Run() starts Playwright, pw.Chromium.Launch() starts the browser, and browser.NewPage() creates the page reused for the batch. The defers close the browser and stop Playwright when main returns. If your program has more complex shutdown needs, close resources explicitly in the relevant cleanup path so failures do not leave browser processes running.

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

The sample continues after an individual navigation or screenshot error, logging the affected URL. That is useful for inventory-style batches where one broken page should not prevent other captures. For a job that must produce a complete set, record failures and make the process exit unsuccessfully after the loop, or fail immediately instead of continuing.

Make output paths deterministic

The output directory is created before capture. Each filename uses the input index, so two URLs with the same path or hostname cannot overwrite each other. If you prefer readable names, derive a filesystem-safe slug from each URL and retain an index as a collision guard. Avoid using raw URLs as filenames: characters such as slashes and query delimiters have filesystem meaning, and long URLs can create awkward paths.

Choose what each screenshot captures

Viewport or full page

With FullPage: playwright.Bool(true), the screenshot includes the scrollable page as though the page were a very tall screen. This is different from a viewport screenshot, which captures only the current visible area. Omit FullPage or set it to false when every capture should represent the same fixed viewport. Playwright documents full-page capture as the entire scrollable page: Playwright screenshot guide.

Full-page output is useful for audits, archives, and visual review of long pages. It can also create very tall images. If your downstream tool expects a standard viewport shape, use viewport capture or capture specific regions instead.

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

Whole page or a selected element

For repeated components—such as a chart, card, header, or product tile—capture a locator rather than the entire page. A locator screenshot focuses the output on the matched element, which can make a large batch easier to inspect and compare. The screenshot API supports both page and locator capture; the exact element selector should match the target site’s markup. See the screenshot guide for the locator approach.

Format and scale

PNG is a sensible default when you want lossless output. The Go screenshot options also support format-related controls such as type and quality, while Playwright documents PNG, JPEG, and WebP output. JPEG or WebP may suit a workflow where file size matters more than lossless pixels; compare results on your own pages because image content and acceptable quality vary. For supported options, see the playwright-go API reference and Playwright screenshot documentation.

Scale determines whether the output uses CSS-pixel dimensions or device-pixel dimensions. CSS scale keeps output dimensions aligned with the page’s CSS layout; device scale produces higher-density output. That can increase pixel dimensions and storage, so choose based on how the images will be reviewed or processed rather than assuming higher scale is always better.

Wait for the page state your capture needs

The example navigates with WaitUntilStateDomcontentloaded. This is a useful baseline, but it only establishes that the document has been parsed; it does not guarantee that a client-rendered application has finished loading its data, images, or animations. If the screenshot must include content created after navigation, wait for a site-specific locator or another meaningful readiness condition before capturing.

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

For example, after Goto succeeds, wait for a stable page marker that only appears when the target content is ready. The selector and wait API details depend on your installed playwright-go version and target site; use the package reference for the exact method signatures. Prefer a condition tied to visible content over an arbitrary long delay, which can waste time on fast pages and still be too short on slow ones.

  • Use DOM content loaded when the initial document is enough.
  • Wait for a known element when the page fills in asynchronously.
  • Use a deliberate timeout and log failures with the URL so slow or broken targets can be distinguished from successful captures.
  • Where pages animate, consider the screenshot options for animation handling so captures are more comparable.

Handle errors and make batches recoverable

Navigation and screenshot calls can fail independently. A site may time out or reject navigation even though other URLs remain capturable; a screenshot can also fail after successful navigation, for example if the output path is not writable. Log the URL and operation as in the sample, and decide whether your batch should continue or stop.

Continue, fail fast, or retry

Continuing is appropriate when partial output has value and you can review a failure report afterward. Fail fast when a partial batch is unsafe—for example, when a downstream process assumes every input has a corresponding image. If you implement retries, limit them and distinguish retryable navigation problems from persistent issues such as invalid URLs or inaccessible output directories. The documented APIs establish the error-returning calls, but do not prescribe a universal retry policy.

Keep a manifest

For recurring or large batches, write a small manifest alongside the images containing the original URL, output path, and success or error status. This makes it possible to rerun failed entries without overwriting or recapturing successful ones. The manifest is application-level bookkeeping, not a Playwright requirement.

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

Sequential capture, concurrency, and performance

The sample is sequential: one page completes navigation and capture before the next URL begins. This has a simple lifecycle, preserves predictable ordering, and avoids creating more browser work than the machine can handle. Reusing the browser and page also avoids launching a fresh browser for every URL.

Parallel capture can reduce elapsed time in some workloads, but it introduces resource and coordination costs: each active page consumes browser resources, output paths must remain unique, and failures become harder to associate with shared state. The cited Playwright documentation does not establish a universal concurrency limit or screenshots-per-second figure. Measure against your own URLs, machine, image size, and readiness waits before adding workers; start conservatively and monitor memory and failures.

Common problems and fixes

  • Playwright fails to start: confirm the Go package is installed and that its browser dependencies are available for the environment. Follow the setup guidance for the package version you use.
  • Some captures show loading placeholders: DOM content loaded may occur before client-rendered content is ready. Wait for the actual content marker before calling Screenshot.
  • Images are missing in full-page output: a page may lazy-load images as it scrolls. The screenshot option captures the page; it does not guarantee every site’s lazy-loading behavior has completed. Add a site-appropriate scroll or readiness strategy and verify the resulting page.
  • Files overwrite one another: ensure each screenshot path is unique. Keep the index even if you also use a slug.
  • Output files cannot be written: create the destination directory and check filesystem permissions before starting a long batch.
  • Captures vary between runs: wait for stable content, use consistent viewport and scale settings, and consider handling animations through screenshot options.
  • Batch takes longer than expected: avoid a new browser launch per URL, avoid unnecessarily long fixed sleeps, and only add concurrency after measuring the workload.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you want a URL-to-image call instead of managing Playwright and Chromium, ScreenshotNeo is a screenshot API and MCP server for developers. Its API accepts a URL and returns a screenshot or PDF. This cURL example saves a WebP capture of a URL:

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

See the ScreenshotNeo documentation for API details. ScreenshotNeo accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots.

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

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Frequently Asked Questions

Can I take screenshots of the same URL in several viewport sizes?

Yes. Set the page viewport for each capture, or create pages with different viewport settings, and give every output a distinct filename. The viewport and device options are documented in Playwright’s screenshot guidance.

Does full-page capture automatically load every lazy image?

Not necessarily. Full-page capture covers the scrollable page, but a site’s lazy-loading behavior may need additional scrolling or a site-specific readiness step before the capture.

Is there a documented maximum number of URLs per Playwright Go batch?

The cited Go and Playwright screenshot references do not specify a universal batch-size limit. Practical limits depend on the machine, target pages, image dimensions, and how the batch is implemented.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Read next

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.