Community研究與資料分析github.com

mindrally/puppeteer-automation

使用 Puppeteer 進行瀏覽器自動化的專家指引,涵蓋網頁爬取、測試、螢幕截圖以及在無頭 Chrome 中執行 JavaScript 的最佳實踐。

puppeteer-automation 是什麼?

此技能「mindrally/puppeteer-automation」專為開發者與 AI 代理提供使用 Puppeteer 進行瀏覽器自動化的專家級指引。它涵蓋網頁爬取、自動化測試、螢幕截圖擷取以及在無頭 Chrome 中執行 JavaScript 的最佳實務做法,幫助使用者高效、穩定地操控瀏覽器。此技能支援所有基於 Node.js 的開發環境,能與 Claude Code、Cursor 等工具無縫整合。透過清晰的案例與程式碼片段,它簡化了 Puppeteer 的學習曲線,並強調錯誤處理與效能最佳化,確保自動化腳本的可靠性。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mindrally/skills/tree/main/skills/puppeteer-automation

Installed? Explore more 研究與資料分析 skills: affaan-m/uspto-database, affaan-m/scholar-evaluation, affaan-m/literature-review · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

puppeteer-automation 是做什麼的?

使用 Puppeteer 進行瀏覽器自動化的專家指引,涵蓋網頁爬取、測試、螢幕截圖以及在無頭 Chrome 中執行 JavaScript 的最佳實踐。

功能概述

  • 網頁爬取:提取靜態與動態內容,包括表單提交與無限滾動頁面。
  • 自動化測試:模擬使用者互動,驗證 UI 元素與頁面行為。
  • 螢幕截圖:捕獲全頁或特定元素的截圖,支援自訂解析度與格式。
  • JavaScript 執行:在頁面上下文中注入並執行自訂腳本,操作 DOM 或獲取資料。
  • 無頭模式:在無頭 Chrome 中運行,節省資源並適合 CI/CD 流程。

支援的平台

  • Node.js:所有版本,建議使用最新的 LTS 版本。
  • Puppeteer:版本 10.0.0 以上。
  • 作業系統:Windows、macOS、Linux。

使用方法

安裝

npm install puppeteer

基本範例

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.screenshot({ path: 'example.png' });
  await browser.close();
})();

進階技巧

  • 等待元素出現:使用 page.waitForSelector 確保頁面載入完成。
  • 處理彈出視窗:監聽 dialog 事件並自動應答。
  • 模擬行動裝置:設定 User-Agent 與 viewport。
  • 錯誤處理:使用 try-catch 區塊捕獲執行錯誤。

注意事項

  • 請遵守目標網站的 robots.txt 條款與使用條款。
  • 頻繁請求可能導致 IP 被封鎖,請適當加入延遲。
  • 使用無頭模式時,需確保系統已安裝 Chrome 或 Chromium。

參考資源

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

mindrally/accessibility-a11y

Implement web accessibility (a11y) best practices following WCAG guidelines to create inclusive, accessible user interfaces.

mindrally/chrome-extension-development

Expert guidelines for Chrome extension development with Manifest V3, covering security, performance, and best practices. Use when building browser extensions, creating popup UIs, implementing content scripts, working with Chrome APIs, managing extension permissions, or publishing to Chrome Web Store.

mindrally/computer-vision-opencv

Expert guidance for computer vision development using OpenCV, PyTorch, and modern deep learning techniques for image and video processing.

mindrally/data-analysis-jupyter

Expert guidance for data analysis, visualization, and Jupyter Notebook development with pandas, matplotlib, seaborn, and numpy.

mindrally/deep-learning-pytorch

Expert guidance for deep learning, transformers, diffusion models, and LLM development with PyTorch, Transformers, Diffusers, and Gradio.

mindrally/expo-react-native-typescript

Expert in Expo React Native TypeScript mobile development with best practices

mindrally/fastapi-python

Expert in FastAPI Python development with best practices for APIs and async operations

mindrally/framer-motion

Expert guidelines for building performant animations with Framer Motion/Motion library in React applications

mindrally/htmx

HTMX development guidelines for building dynamic web applications with minimal JavaScript using HTML attributes.

mindrally/jwt-security

Guidelines for implementing JWT authentication with security best practices for token creation, validation, and storage

mindrally/machine-learning

Machine learning development with JAX, functional programming patterns, and high-performance computing.

mindrally/mysql-best-practices

MySQL development best practices for schema design, query optimization, and database administration

mindrally/nextjs-react-typescript

Expert in TypeScript, Node.js, Next.js App Router, React, Shadcn UI, Radix UI and Tailwind

mindrally/nextjs-typescript-tailwindcss-supabase

Full-stack Next.js 14 development with TypeScript, TailwindCSS, and Supabase for building production-ready web applications.

mindrally/odoo-development

Expert guidance for Odoo ERP development including Python ORM, XML views, and module architecture

mindrally/redis-best-practices

Redis development best practices for caching, data structures, and high-performance key-value operations

mindrally/scrapy-web-scraping

Expert guidance for building web scrapers and crawlers using the Scrapy Python framework with best practices for spider development, data extraction, and pipeline management.

mindrally/scss-best-practices

SCSS/Sassy CSS best practices and coding guidelines for maintainable, scalable stylesheets

mindrally/typeorm

Guidelines for developing with TypeORM, a full-featured ORM for TypeScript and JavaScript supporting multiple databases

mindrally/web-scraping

Expert in web scraping and data extraction with Python tools

相關技能