When to Use(中文场景)
- - 用户要求「截取某个网页」
- 用户要求「保存网页快照」「截图存档」
- 做 QA 对比、报告配图
- 需要把网页导出为 PDF
- 快速查看某个 URL 的视觉效果
- 登录后才可见的页面:不支持,详见 Limitations
适用场景示例
CODEBLOCK0
Tool
Playwright Node.js (via npx cache, no install needed)
Path: INLINECODE0
Quick Use — Shell Script
CODEBLOCK1
Examples:
CODEBLOCK2
Quick Use — Inline Node.js
CODEBLOCK3
Parameters
| Parameter | Default | Notes |
|---|
| URL | required | Target URL, must be valid |
| output path |
auto timestamp |
/tmp/openclaw/screenshot_YYYYMMDD_HHMMSS.png |
|
--fullpage | viewport only | Captures entire scrollable page |
|
--pdf | screenshot | Exports as A4 PDF |
Tips
- - For Chinese content: Playwright handles UTF-8 fine, no extra config needed
- For dynamic pages: increase
waitForTimeout (e.g. 5000 instead of 2000) - For PDF:
printBackground: true ensures background colors/images are included - Output size: ~100-150KB for typical pages, ~300KB+ for full-page
Limitations
Login-gated / anti-automation pages: Some sites detect headless browsers and return blank content. Workaround:
- - Use the site's API for data instead of screenshots
- Use a real logged-in browser for those pages
- Public static pages work fine
Known sites with issues: GitHub (sometimes), A2H Market (confirmed), sites with Cloudflare protection
使用时机(中文场景)
- - 用户要求「截取某个网页」
- 用户要求「保存网页快照」「截图存档」
- 做 QA 对比、报告配图
- 需要把网页导出为 PDF
- 快速查看某个 URL 的视觉效果
- 登录后才可见的页面:不支持,详见限制说明
适用场景示例
用户:帮我截一下这个知乎回答
用户:把百度搜索结果截图发给我
用户:这个公众号文章截图存档
用户:把这个页面导出PDF
用户:全页面截图,要看到页面底部
工具
Playwright Node.js(通过 npx 缓存,无需安装)
路径:/root/.npm/npx/e41f203b7505f1fb/nodemodules
快速使用 — Shell 脚本
bash
bash skills/web-screenshot/scripts/screenshot.sh [output] [--fullpage|--pdf]
示例:
bash
基础截图(视口大小)
bash scripts/screenshot.sh https://www.baidu.com /tmp/baidu.png
全页面截图(滚动捕获整个页面)
bash scripts/screenshot.sh https://example.com /tmp/full.png --fullpage
导出为 PDF
bash scripts/screenshot.sh https://example.com /tmp/page.pdf --pdf
快速使用 — 内联 Node.js
bash
NODEPATH=/root/.npm/npx/e41f203b7505f1fb/node_modules node -e
const { chromium } = require(playwright);
(async () => {
const browser = await chromium.launch({ headless: true, args: [--no-sandbox] });
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
await page.goto(YOUR_URL, { waitUntil: domcontentloaded, timeout: 15000 });
await page.waitForTimeout(2000);
await page.screenshot({ path: /tmp/output.png, fullPage: false });
await browser.close();
})().catch(e => { console.error(e.message); process.exit(1); });
参数
| 参数 | 默认值 | 说明 |
|---|
| URL | 必填 | 目标 URL,必须有效 |
| 输出路径 |
自动时间戳 | /tmp/openclaw/screenshot
YYYYMMDDHHMMSS.png |
| --fullpage | 仅视口 | 捕获整个可滚动页面 |
| --pdf | 截图 | 导出为 A4 格式 PDF |
提示
- - 中文内容:Playwright 完美支持 UTF-8,无需额外配置
- 动态页面:增加 waitForTimeout 等待时间(例如 5000 代替 2000)
- PDF 导出:设置 printBackground: true 确保包含背景颜色和图片
- 输出大小:普通页面约 100-150KB,全页面约 300KB 以上
限制说明
需要登录/反自动化页面:部分网站会检测无头浏览器并返回空白内容。解决方法:
- - 使用网站 API 获取数据代替截图
- 对这类页面使用真实登录的浏览器
- 公开静态页面可正常使用
已知有问题的网站:GitHub(偶尔)、A2H Market(已确认)、带有 Cloudflare 保护的网站