← 返回命令列表

Linux command

shot-scraper 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Take a screenshot

shot-scraper [https://example.com]

Take a screenshot

shot-scraper [https://example.com] -w [800] -h [600] -o [output.png]

Capture a specific element

shot-scraper [https://example.com] -s '[.header]' -o [header.png]

Take a screenshot

shot-scraper [https://example.com] --javascript "[document.body.style.backgroundColor = 'white']"

Take a retina screenshot

shot-scraper [https://example.com] --retina -o [output.png]

Wait for element

shot-scraper [https://example.com] --wait-for "[document.querySelector('.loaded')]"

Save as JPEG

shot-scraper [https://example.com] -o [output.jpg] --quality [80]

Interactive mode

shot-scraper [https://example.com] --interactive

说明

shot-scraper is a command-line utility for taking automated screenshots of websites, built on Playwright. It can capture full pages, specific elements, or execute JavaScript before capturing. The tool is designed for documentation, automated testing, and web scraping workflows. Beyond screenshots, shot-scraper can execute JavaScript on pages and return results, generate PDFs, export accessibility trees, and capture HAR (HTTP Archive) files. It integrates well with CI/CD pipelines, particularly GitHub Actions, for generating regularly updated screenshots. Before first use, run shot-scraper install to download the required browser binaries.

参数

-o, --output _FILE_
Output filename. Use - for stdout.
-w, --width _PIXELS_
Browser viewport width. Default: 1280.
-h, --height _PIXELS_
Browser viewport height. Default: full page.
-s, --selector _SELECTOR_
CSS selector to capture instead of full page.
--selector-all _SELECTOR_
Capture all elements matching the selector.
--padding _PIXELS_
Add padding around selected elements.
--js-selector _EXPRESSION_
JavaScript expression to filter elements.
--wait _MS_
Milliseconds to wait after page load.
--wait-for _EXPRESSION_
Wait until JavaScript expression is truthy.
-j, --javascript _CODE_
Execute JavaScript before taking screenshot.
--quality _PERCENT_
Save as JPEG with specified quality (1-100).
--retina
Use device scale factor of 2.
--scale-factor _N_
Custom device pixel ratio.
--omit-background
Transparent background (PNG only).
-b, --browser _NAME_
Browser to use: chromium, firefox, webkit, chrome.
--browser-arg _ARG_
Pass command-line argument to browser.
--user-agent _STRING_
Custom User-Agent header.
-i, --interactive
Pause for manual interaction before capture.
--bypass-csp
Bypass Content-Security-Policy restrictions.
--log-requests _FILE_
Log HTTP requests as newline-delimited JSON.
--timeout _MS_
Timeout in milliseconds before failing.

FAQ

What is the shot-scraper command used for?

shot-scraper is a command-line utility for taking automated screenshots of websites, built on Playwright. It can capture full pages, specific elements, or execute JavaScript before capturing. The tool is designed for documentation, automated testing, and web scraping workflows. Beyond screenshots, shot-scraper can execute JavaScript on pages and return results, generate PDFs, export accessibility trees, and capture HAR (HTTP Archive) files. It integrates well with CI/CD pipelines, particularly GitHub Actions, for generating regularly updated screenshots. Before first use, run shot-scraper install to download the required browser binaries.

How do I run a basic shot-scraper example?

Run `shot-scraper [https://example.com]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -o, --output _FILE_ do in shot-scraper?

Output filename. Use - for stdout.