jpskill.com
💼 ビジネス コミュニティ

crawl4ai

Crawl4AIのエキスパートとして、AI向けのウェブクローラーを活用し、ウェブサイトからLLM学習やRAGパイプラインに必要な構造化されたデータを抽出し、自動markdown変換やJavaScriptレンダリングなどの機能で効率的なデータ収集を支援するSkill。

📜 元の英語説明(参考)

You are an expert in Crawl4AI, the open-source web crawler built for AI applications. You help developers extract clean, structured data from websites for LLM training, RAG pipelines, and content analysis — with automatic markdown conversion, JavaScript rendering, CSS-based extraction, LLM-powered structured extraction, and session management for multi-page crawling.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Crawl4AIのエキスパートとして、AI向けのウェブクローラーを活用し、ウェブサイトからLLM学習やRAGパイプラインに必要な構造化されたデータを抽出し、自動markdown変換やJavaScriptレンダリングなどの機能で効率的なデータ収集を支援するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o crawl4ai.zip https://jpskill.com/download/14796.zip && unzip -o crawl4ai.zip && rm crawl4ai.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/14796.zip -OutFile "$d\crawl4ai.zip"; Expand-Archive "$d\crawl4ai.zip" -DestinationPath $d -Force; ri "$d\crawl4ai.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して crawl4ai.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → crawl4ai フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Crawl4AI — LLMフレンドリーなウェブクローラー

Crawl4AIのエキスパートとして、AIアプリケーション向けに構築されたオープンソースのウェブクローラーについてご説明します。開発者がウェブサイトからクリーンで構造化されたデータを抽出し、LLMトレーニング、RAGパイプライン、コンテンツ分析に利用できるよう支援します。自動Markdown変換、JavaScriptレンダリング、CSSベースの抽出、LLMによる構造化抽出、複数ページクロール用のセッション管理などの機能を提供します。

主要な機能

基本的なクローリング

from crawl4ai import AsyncWebCrawler, CrawlerRunConfig, CacheMode

async with AsyncWebCrawler() as crawler:
    result = await crawler.arun(
        url="https://docs.example.com/getting-started",
        config=CrawlerRunConfig(
            word_count_threshold=10,       # 10単語未満のブロックをスキップ
            cache_mode=CacheMode.ENABLED,
        ),
    )

    print(result.markdown)                 # クリーンなMarkdown (LLM対応)
    print(result.cleaned_html)             # クリーンなHTML
    print(result.media["images"])          # 抽出された画像
    print(result.links["internal"])        # 内部リンク
    print(result.links["external"])        # 外部リンク
    print(result.metadata)                 # タイトル、説明、キーワード

LLMによる構造化抽出

from crawl4ai import AsyncWebCrawler, CrawlerRunConfig
from crawl4ai.extraction_strategy import LLMExtractionStrategy
from pydantic import BaseModel

class Product(BaseModel):
    name: str
    price: float
    description: str
    rating: float | None
    features: list[str]

extraction = LLMExtractionStrategy(
    provider="openai/gpt-4o-mini",
    api_token=os.environ["OPENAI_API_KEY"],
    schema=Product.model_json_schema(),
    instruction="Extract all products from this page",
)

async with AsyncWebCrawler() as crawler:
    result = await crawler.arun(
        url="https://shop.example.com/keyboards",
        config=CrawlerRunConfig(extraction_strategy=extraction),
    )

    products = [Product(**p) for p in json.loads(result.extracted_content)]
    for p in products:
        print(f"{p.name}: ${p.price} — {p.rating}★")

CSSベースの抽出 (LLMなし)

from crawl4ai.extraction_strategy import JsonCssExtractionStrategy

schema = {
    "name": "Product listings",
    "baseSelector": ".product-card",       # 繰り返し要素
    "fields": [
        {"name": "title", "selector": "h3.product-title", "type": "text"},
        {"name": "price", "selector": ".price", "type": "text"},
        {"name": "url", "selector": "a", "type": "attribute", "attribute": "href"},
        {"name": "image", "selector": "img", "type": "attribute", "attribute": "src"},
    ],
}

extraction = JsonCssExtractionStrategy(schema)

async with AsyncWebCrawler() as crawler:
    result = await crawler.arun(
        url="https://shop.example.com/all",
        config=CrawlerRunConfig(
            extraction_strategy=extraction,
            js_code="window.scrollTo(0, document.body.scrollHeight);",  # スクロールしてさらに読み込む
            wait_for=".product-card:nth-child(20)",                     # 20個のアイテムを待つ
        ),
    )
    products = json.loads(result.extracted_content)

複数ページのクローリング

from crawl4ai import AsyncWebCrawler, CrawlerRunConfig

async with AsyncWebCrawler() as crawler:
    # セッションベース: Cookie、認証状態を維持
    session_id = "docs-crawl"

    # まずログイン
    await crawler.arun(
        url="https://docs.example.com/login",
        config=CrawlerRunConfig(
            session_id=session_id,
            js_code="""
                document.querySelector('#email').value = 'user@example.com';
                document.querySelector('#password').value = 'pass';
                document.querySelector('form').submit();
            """,
            wait_for="#dashboard",
        ),
    )

    # 認証されたページをクロール
    urls = ["https://docs.example.com/api", "https://docs.example.com/guides"]
    for url in urls:
        result = await crawler.arun(
            url=url,
            config=CrawlerRunConfig(session_id=session_id),
        )
        # RAGインデックス作成のためにMarkdownを保存
        save_to_knowledge_base(url, result.markdown)

インストール

pip install crawl4ai
crawl4ai-setup                             # Playwrightブラウザをインストール

ベストプラクティス

  1. Markdown出力 — LLM/RAG入力にはresult.markdownを使用してください。クリーンで構造化されており、HTMLノイズはありません。
  2. CSS抽出 — 構造化されたページにはJsonCssExtractionStrategyを使用してください。LLMコストがかからず、高速で、決定論的です。
  3. LLM抽出 — 構造化されていないページにはLLMExtractionStrategyを使用してください。Pydanticスキーマにより、有効な出力が保証されます。
  4. JavaScriptレンダリング — Crawl4AIはPlaywrightを使用します。SPA、無限スクロール、動的コンテンツを処理します。
  5. セッション — 複数ページのクロールにはsession_idを使用してください。リクエスト間でCookie、認証状態を維持します。
  6. キャッシュ — 開発にはCacheMode.ENABLEDを有効にしてください。同じページを再クロールすることを避けます。
  7. 待機条件 — 抽出前にコンテンツがロードされていることを確認するために、wait_for CSSセレクターを使用してください。
  8. レート制限 — リクエスト間に遅延を追加してください。robots.txtを尊重してください。良き市民でありましょう。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Crawl4AI — LLM-Friendly Web Crawler

You are an expert in Crawl4AI, the open-source web crawler built for AI applications. You help developers extract clean, structured data from websites for LLM training, RAG pipelines, and content analysis — with automatic markdown conversion, JavaScript rendering, CSS-based extraction, LLM-powered structured extraction, and session management for multi-page crawling.

Core Capabilities

Basic Crawling

from crawl4ai import AsyncWebCrawler, CrawlerRunConfig, CacheMode

async with AsyncWebCrawler() as crawler:
    result = await crawler.arun(
        url="https://docs.example.com/getting-started",
        config=CrawlerRunConfig(
            word_count_threshold=10,       # Skip blocks with <10 words
            cache_mode=CacheMode.ENABLED,
        ),
    )

    print(result.markdown)                 # Clean markdown (LLM-ready)
    print(result.cleaned_html)             # Cleaned HTML
    print(result.media["images"])          # Extracted images
    print(result.links["internal"])        # Internal links
    print(result.links["external"])        # External links
    print(result.metadata)                 # Title, description, keywords

LLM-Powered Structured Extraction

from crawl4ai import AsyncWebCrawler, CrawlerRunConfig
from crawl4ai.extraction_strategy import LLMExtractionStrategy
from pydantic import BaseModel

class Product(BaseModel):
    name: str
    price: float
    description: str
    rating: float | None
    features: list[str]

extraction = LLMExtractionStrategy(
    provider="openai/gpt-4o-mini",
    api_token=os.environ["OPENAI_API_KEY"],
    schema=Product.model_json_schema(),
    instruction="Extract all products from this page",
)

async with AsyncWebCrawler() as crawler:
    result = await crawler.arun(
        url="https://shop.example.com/keyboards",
        config=CrawlerRunConfig(extraction_strategy=extraction),
    )

    products = [Product(**p) for p in json.loads(result.extracted_content)]
    for p in products:
        print(f"{p.name}: ${p.price} — {p.rating}★")

CSS-Based Extraction (No LLM)

from crawl4ai.extraction_strategy import JsonCssExtractionStrategy

schema = {
    "name": "Product listings",
    "baseSelector": ".product-card",       # Repeating element
    "fields": [
        {"name": "title", "selector": "h3.product-title", "type": "text"},
        {"name": "price", "selector": ".price", "type": "text"},
        {"name": "url", "selector": "a", "type": "attribute", "attribute": "href"},
        {"name": "image", "selector": "img", "type": "attribute", "attribute": "src"},
    ],
}

extraction = JsonCssExtractionStrategy(schema)

async with AsyncWebCrawler() as crawler:
    result = await crawler.arun(
        url="https://shop.example.com/all",
        config=CrawlerRunConfig(
            extraction_strategy=extraction,
            js_code="window.scrollTo(0, document.body.scrollHeight);",  # Scroll to load more
            wait_for=".product-card:nth-child(20)",                     # Wait for 20 items
        ),
    )
    products = json.loads(result.extracted_content)

Multi-Page Crawling

from crawl4ai import AsyncWebCrawler, CrawlerRunConfig

async with AsyncWebCrawler() as crawler:
    # Session-based: maintains cookies, auth state
    session_id = "docs-crawl"

    # Login first
    await crawler.arun(
        url="https://docs.example.com/login",
        config=CrawlerRunConfig(
            session_id=session_id,
            js_code="""
                document.querySelector('#email').value = 'user@example.com';
                document.querySelector('#password').value = 'pass';
                document.querySelector('form').submit();
            """,
            wait_for="#dashboard",
        ),
    )

    # Crawl authenticated pages
    urls = ["https://docs.example.com/api", "https://docs.example.com/guides"]
    for url in urls:
        result = await crawler.arun(
            url=url,
            config=CrawlerRunConfig(session_id=session_id),
        )
        # Save markdown for RAG indexing
        save_to_knowledge_base(url, result.markdown)

Installation

pip install crawl4ai
crawl4ai-setup                             # Install Playwright browsers

Best Practices

  1. Markdown output — Use result.markdown for LLM/RAG input; clean, structured, no HTML noise
  2. CSS extraction — Use JsonCssExtractionStrategy for structured pages; no LLM cost, fast, deterministic
  3. LLM extraction — Use LLMExtractionStrategy for unstructured pages; Pydantic schema ensures valid output
  4. JavaScript rendering — Crawl4AI uses Playwright; handles SPAs, infinite scroll, dynamic content
  5. Sessions — Use session_id for multi-page crawls; maintains cookies, auth state across requests
  6. Caching — Enable CacheMode.ENABLED for development; avoid re-crawling the same pages
  7. Wait conditions — Use wait_for CSS selectors to ensure content is loaded before extraction
  8. Rate limiting — Add delays between requests; respect robots.txt; be a good citizen