shot-scraper
$ shot-scraper 社区开源 中风险shot-scraper 将 Playwright 封装为简洁的单行子命令:截取 PNG、导出 PDF、查看无障碍树(accessibility),或通过 shot-scraper javascript 执行页面脚本并直接返回 JSON。
brew install shot-scraper 单页 javascript JSON 提取与视觉 shot 验收非常趁手;多步有状态交互流程请交给浏览器子 Agent。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
javascript 与 accessibility 子命令可直接向 stdout 输出纯净 JSON,无任何交互阻塞。
shot-scraper javascriptandaccessibilityoutput JSON to stdout
单次读取/渲染操作为主,但无头浏览器会执行目标页面 JS,且需注意勿将 --auth 凭据带入不可信站点。
- Read-only DOM extraction unless
-owrites image/PDF locally
可通过 pip/brew/uvx 安装,但首次使用需执行 shot-scraper install 下载 Chromium。
- Python CLI requiring Playwright browser binary download
替代手写临时 Playwright 脚本的零样板工具,兼顾截图、PDF 与 DOM JSON 抽取。
- Single-command screenshot, PDF, accessibility, and JS-to-JSON execution
由 Simon Willison(simonw/shot-scraper)维护,Apache-2.0 协议。
simonw/shot-scraperrepository
shot-scraper.datasette.io 官方文档清晰易读。
- Official docs at shot-scraper.datasette.io
安全边界、鉴权与放权指南
支持临时传入 --auth JSON 会话文件、--auth-user/--auth-password 或请求头;默认不保存凭据。
免费开源(Apache-2.0 协议)Python CLI;需下载 Playwright Chromium 内核。
# shot-scraper Agent Rules - Run `shot-scraper install` once per environment if Chromium is not yet cached. - Bound long-running pages with `--timeout <ms>` and avoid passing `--auth` state files to untrusted URLs.
Agent 高频安全命令配方
只读查询(安全推荐)
shot-scraper javascript https://example.com "({title: document.title, h1: document.querySelector('h1')?.innerText})" 无头加载页面并执行 JS,向 stdout 打印干净的 JSON 数据。
shot-scraper accessibility http://localhost:4321
无需保存图片文件即可导出浏览器的无障碍树 JSON 结构。
受控写入与预演
shot-scraper http://localhost:4321 -s '#main' -w 1280 -o preview.png
在 1280px 视口下渲染 #main 区域并保存为本地 preview.png。
核心优势
- +
shot-scraper javascript与accessibility无需编写脚本文件即可直接返回 JSON。 - + 提供开箱即用的选择器(
-s)、视口(-w/-h)和--wait视觉验收参数。
注意事项与踩坑点
- ! 新环境需额外运行
shot-scraper install下载约 300 MB Chromium。 - ! 定位为单页单次执行,不适合多步登录或复杂状态流。