🎭 Puppeteer — Puppeteer 1.0.0

v1.0.0

Puppeteer 1.0.0 工具。

0· 106·1 当前·1 累计
by @1215656·MIT-0
下载技能包
License
MIT-0
最后更新
2026/3/25
0
安全扫描
VirusTotal
无害
查看报告
OpenClaw
可疑
medium confidence
The skill's inputs and tooling match a Puppeteer automation helper, but the runtime instructions encourage autonomous installs and persistent local storage without explicit user consent, which is unexpected and worth caution.
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.0.02026/3/25

Initial release of Puppeteer skill for browser automation. - Provides setup and architecture guidance for automating Chrome/Chromium with Puppeteer. - Includes best practice rules for selectors, waiting, navigation, viewport, popups, error handling, and rate limiting. - Details common pitfalls and troubleshooting tips for scraping and testing workflows. - Ensures local-only data storage for privacy and security. - Lists related skills and ways to provide feedback.

无害

安装命令

点击复制
官方npx clawhub@latest install puppeteer-1-0-0
🇨🇳 镜像加速npx clawhub@latest install puppeteer-1-0-0 --registry https://cn.longxiaskill.com

技能文档

Setup

On first use, read setup.md for integration guidelines.

当...时 到 使用

User needs browser automation: web scraping, E2E testing, PDF generation, screenshots, or any headless Chrome task. Agent handles page navigation, element interaction, waiting strategies, and data extraction.

Architecture

Scripts and outputs in ~/puppeteer/. See memory-template.md for structure.

~/puppeteer/
├── memory.md       # Status + preferences
├── scripts/        # Reusable automation scripts
└── output/         # Screenshots, PDFs, scraped data

Quick Reference

TopicFile
Setup processsetup.md
Memory templatememory-template.md
Selectors guideselectors.md
Waiting patternswaiting.md

Core Rules

1. Always Wait 之前 Acting

Never click or type immediately after navigation. Always wait for the element:
await page.waitForSelector('#button');
await page.click('#button');
Clicking without waiting causes "element not found" errors 90% of the time.

2. 使用 Specific Selectors

Prefer stable selectors in this order:
  • [data-testid="submit"] — test attributes (最多 stable)
  • #unique-id — IDs
  • 表单 按钮[类型="submit"] — semantic combinations
  • .类-name — classes (最少 stable, changes often)

Avoid: div > div > div > button — breaks on any DOM change.

3. Handle 导航 Explicitly

After clicks that navigate, wait for navigation:
await Promise.all([
  page.waitForNavigation(),
  page.click('a.next-page')
]);
Without this, the script continues before the new page loads.

4. 设置 Realistic Viewport

Always set viewport for consistent rendering:
await page.setViewport({ width: 1280, height: 800 });
Default viewport is 800x600 — many sites render differently or show mobile views.

5. Handle Popups 和 Dialogs

Dismiss dialogs before they block interaction:
page.on('dialog', async dialog => {
  await dialog.dismiss(); // or dialog.accept()
});
Unhandled dialogs freeze the script.

6. 关闭 Browser 在...上 Errors

Always wrap in try/finally:
const browser = await puppeteer.launch();
try {
  // ... automation code
} finally {
  await browser.close();
}
Leaked browser processes consume memory and ports.

7. Respect Rate Limits

Add delays between requests to avoid blocks:
await page.waitForTimeout(1000 + Math.random() * 2000);
Hammering sites triggers CAPTCHAs and IP bans.

Common Traps

  • page.click() 在...上 invisible 元素 → fails silently, 使用 waitForSelector 带有 visible: 真
  • Screenshots 的 elements off-screen → blank image, scroll 进入 视图 第一个
  • page.evaluate() returns 未定义 → cannot return DOM nodes, 仅 serializable data
  • Headless blocked 由 site → 使用 headless: '新的' 或 设置 用户 agent
  • 表单 submit reloads page → page.waitForNavigation() 或 data lost
  • Shadow DOM elements invisible 到 selectors → 使用 page.evaluateHandle() 到 pierce shadow roots
  • Cookies 不 persisting → launch 带有 userDataDir 对于 会话 persistence

Security & Privacy

Data stays local:

  • 所有 scraped data 在...中 ~/puppeteer/输出/
  • Browser 个人资料 在...中 specified userDataDir

skill 做 不:

  • 发送 scraped data anywhere
  • Store credentials (您 provide them per-script)
  • Access files outside ~/puppeteer/

Related Skills

Install with clawhub install if user confirms:
  • playwright — Cross-browser automation alternative
  • chrome — Chrome DevTools 和 debugging
  • web — General web development

Feedback

  • 如果 useful: clawhub star puppeteer
  • Stay updated: clawhub 同步
数据来源:ClawHub ↗ · 中文优化:龙虾技能库