Skip to content

截图选项

🖼️ 控制截图的格式、范围与分辨率。

标志

标志默认说明
--screenshot-pathscreenshots截图保存目录
--screenshot-formatpng格式(png/jpeg
--screenshot-quality90JPEG 质量(1-100,仅 jpeg)
--skip-screenshotfalse跳过保存截图(仅采集证据)
--full-pagefalse截完整页面(含滚动区域)
--selectorCSS 选择器,仅截匹配元素
--xpathXPath,仅截匹配元素
--resolution-x1280窗口宽度
--resolution-y800窗口高度

截图模式

截图参数从下发、CDP 渲染到落盘的时序:

示例

bash
# 视口截图(默认)
snir scan example.com

# 完整长页面
snir scan example.com --full-page

# 截某元素
snir scan example.com --selector "#main-content"
snir scan example.com --xpath "//div[@class='hero']"

# JPEG + 质量
snir scan example.com --screenshot-format jpeg --screenshot-quality 80

# 高分辨率
snir scan example.com --resolution-x 1920 --resolution-y 1080

# 仅证据不截图
snir scan example.com --skip-screenshot --save-html --save-headers

格式选择

PNG vs JPEG,按用途选

格式体积清晰度适合
PNG(默认)无损需看清文字/UI 细节、要 OCR、要证据留档
JPEG有损批量存档、缩略图网格、对体积敏感

JPEG 用 --screenshot-quality(1-100)控制压缩率,80 是体积/质量的甜点。

文件命名

文件名自动清理,跨平台安全

截图文件名经 SanitizeFilename 清理非法字符(\ / : * ? " < > | %),把 URL 里这些字符替换掉——保证同一张图在 Windows/Linux/macOS 都能落盘,不会因文件名非法报错。

下一步

基于 MIT 许可发布