Community研究&データ分析github.com

mindrally/puppeteer-automation

Puppeteer を使用したブラウザ自動化の専門ガイダンス。Web スクレイピング、テスト、スクリーンショット取得、ヘッドレス Chrome での JavaScript 実行のベストプラクティスを提供します。

puppeteer-automation とは?

このスキルは、Puppeteer を用いたブラウザ自動化に関する専門的な知識とベストプラクティスを提供します。主に Web スクレイピング、E2E テスト、スクリーンショット撮影、ヘッドレス Chrome 環境での JavaScript 実行といったタスクに対して、効率的でエラー耐性のあるコードの記述方法を支援します。具体的には、非同期処理の適切な制御、ページ要素の待機戦略、キーボード・マウス操作のシミュレーション、ネットワークリクエストのモック化、生成 AI(LLM)との統合手法など、実践的なテクニックをカバーしています。Claude Code や Codex などの AI エージェントと組み合わせて利用することで、開発者はブラウザ自動化の複雑なロジックを迅速に実装でき、テスト自動化やデータ収集の生産性を大幅に向上させることができます。

対応~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に質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

puppeteer-automation は何をしますか?

Puppeteer を使用したブラウザ自動化の専門ガイダンス。Web スクレイピング、テスト、スクリーンショット取得、ヘッドレス Chrome での JavaScript 実行のベストプラクティスを提供します。

主要機能

  • Web スクレイピング: 動的ページからのデータ抽出、無限スクロール対応、認証が必要なサイトへのアクセス。
  • テスト自動化: E2E テスト、フォーム送信、UI 検証。
  • スクリーンショット/PDF: 特定要素のキャプチャ、フルページスクリーンショット、PDF 生成。
  • JavaScript 実行: ページコンテキストでのコードインジェクション、変数抽出。
  • ネットワーク制御: リクエストインターセプト、レスポンスモック、スロットリング。

使用方法

インストール

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: 'screenshot.png' });
  
  const title = await page.title();
  console.log(`ページタイトル: ${title}`);
  
  await browser.close();
})();

ベストプラクティス

  1. エラーハンドリング: 非同期処理には常に try/catch ブロックを使用する。
  2. リソース管理: スクレイピング後は必ず browser.close() を呼び出してリソースを解放する。
  3. セレクター戦略: 変更に強い ID や data-testid 属性を使用し、フラジャイルな CSS クラスは避ける。
  4. 待機戦略: page.waitForSelector() や page.waitForNetworkIdle() で適切に待機する。固定の setTimeout() は避ける。
  5. ユーザーエージェントとビューポート: 実際のブラウザエミュレーションには適切な UA とビューポートサイズを設定する。

高度なテクニック

  • 複数タブの操作: browser.pages() でタブを管理する。
  • 認証の処理: page.authenticate() または Cookie の設定を使用する。
  • ファイルダウンロード: ダウンロードフォルダを指定してファイルをキャプチャする。
  • Chrome DevTools Protocol (CDP): page.cdpSession() で低レベル制御を行う。

注意事項

  • 対象 Web サイトの robots.txt と利用規約を常に尊重すること。
  • 過剰なリクエストによるサーバー負荷を避けるため、適切なレート制限を実装すること。
  • スクレイピングしたデータの法的利用について確認すること。

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

関連スキル