mcpField
F
firecrawl-scraper

firecrawl-scraper

github.com/benedictkingデータ・データベース10607 回インストール27 週間前に更新
リポジトリ

firecrawl-scraper について

firecrawl-scraper は、Firecrawl のエンドポイントを選んで呼び出すスキルです。ページやサイトのコンテンツ抽出、URL の発見、複数ページの処理に使えます。

主な機能

  1. 01複数形式でのページ取得
  2. 02深度とパスを指定したサイト巡回
  3. 03サイト URL の検出
  4. 04複数 URL の並列取得
  5. 05ブラウザー操作によるページ制御
  6. 06巡回ジョブの状態確認

活用シーン

  1. 01ページから Markdown や HTML を抽出
  2. 02サイト内の URL を収集
  3. 03指定したドキュメントパスを巡回
  4. 04複数ページから構造化データを抽出

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/benedictking/firecrawl-scraper --skill firecrawl-scraper

インストール後、Claude Code で/firecrawl-scraperを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

.env.example
.gitignore
firecrawl-api.cjs
firecrawl-fetcher.md

詳細

Firecrawl スクレイパースキル

トリガー条件とエンドポイントの選択

ユーザーの意図に基づいて Firecrawl のエンドポイントを選択します。

  • scrape:単一の Web ページからコンテンツ(markdown、html、json、スクリーンショット、PDF)を抽出する必要がある場合
  • crawl:深さの制御やパスのフィルタリングを行いながら、Web サイト全体をクロールする必要がある場合
  • map:Web サイト上のすべての URL の一覧をすばやく取得する必要がある場合
  • batch-scrape:複数の URL を並列でスクレイピングする必要がある場合
  • crawl-status:クロールジョブ ID を指定して、クロールの進行状況や結果を確認する場合(--wait は任意)

推奨アーキテクチャ(メインスキル + サブスキル)

このスキルでは、次の 2 段階のアーキテクチャを使用します。

  1. メインスキル(現在のコンテキスト):ユーザーの質問を理解する → エンドポイントを選択する → JSON ペイロードを組み立てる
  2. サブスキル(フォークされたコンテキスト):HTTP 呼び出しの実行のみを担当し、会話履歴によるトークンの浪費を避ける

実行方法

Task ツールを使って firecrawl-fetcher サブスキルを呼び出し、コマンドと JSON(stdin)を渡します。

Task parameters:
- subagent_type: Bash
- description: "Call Firecrawl API"
- prompt: cat <<'JSON' | node .claude/skills/firecrawl-scraper/firecrawl-api.cjs <scrape|crawl|map|batch-scrape|crawl-status> [--wait]
  { ...payload... }
  JSON

ペイロードの例

1) 単一ページのスクレイピング
cat <<'JSON' | node .claude/skills/firecrawl-scraper/firecrawl-api.cjs scrape
{
  "url": "https://example.com",
  "formats": ["markdown", "links"],
  "onlyMainContent": true,
  "includeTags": [],
  "excludeTags": ["nav", "footer"],
  "waitFor": 0,
  "timeout": 30000
}
JSON

利用可能な形式:

  • "markdown"、"html"、"rawHtml"、"links"、"images"、"summary"
  • {"type": "json", "prompt": "Extract product info", "schema": {...}}
  • {"type": "screenshot", "fullPage": true, "quality": 85}
2) アクションを使ったスクレイピング(ページ操作)
cat <<'JSON' | node .claude/skills/firecrawl-scraper/firecrawl-api.cjs scrape
{
  "url": "https://example.com",
  "formats": ["markdown"],
  "actions": [
    {"type": "wait", "milliseconds": 2000},
    {"type": "click", "selector": "#load-more"},
    {"type": "wait", "milliseconds": 1000},
    {"type": "scroll", "direction": "down", "amount": 500}
  ]
}
JSON

利用可能なアクション:

  • wait、click、write、press、scroll、screenshot、scrape、executeJavascript
3) PDF の解析
cat <<'JSON' | node .claude/skills/firecrawl-scraper/firecrawl-api.cjs scrape
{
  "url": "https://example.com/document.pdf",
  "formats": ["markdown"],
  "parsers": ["pdf"]
}
JSON
4) 構造化 JSON の抽出
cat <<'JSON' | node .claude/skills/firecrawl-scraper/firecrawl-api.cjs scrape
{
  "url": "https://example.com/product",
  "formats": [
    {
      "type": "json",
      "prompt": "Extract product information",
      "schema": {
        "type": "object",
        "properties": {
          "name": {"type": "string"},
          "price": {"type": "number"},
          "description": {"type": "string"}
        },
        "required": ["name", "price"]
      }
    }
  ]
}
JSON
5) Web サイト全体のクロール
cat <<'JSON' | node .claude/skills/firecrawl-scraper/firecrawl-api.cjs crawl
{
  "url": "https://docs.example.com",
  "formats": ["markdown"],
  "includePaths": ["^/docs/.*"],
  "excludePaths": ["^/blog/.*"],
  "maxDiscoveryDepth": 3,
  "limit": 100,
  "allowExternalLinks": false,
  "allowSubdomains": false
}
JSON
5.1) クロールの完了を待機
cat <<'JSON' | node .claude/skills/firecrawl-scraper/firecrawl-api.cjs crawl --wait
{
  "url": "https://docs.example.com",
  "formats": ["markdown"],
  "limit": 100
}
JSON
6) Web サイトの URL のマッピング
cat <<'JSON' | node .claude/skills/firecrawl-scraper/firecrawl-api.cjs map
{
  "url": "https://example.com",
  "search": "documentation",
  "limit": 5000
}
JSON
7) 複数 URL の一括スクレイピング
cat <<'JSON' | node .claude/skills/firecrawl-scraper/firecrawl-api.cjs batch-scrape
{
  "urls": [
    "https://example.com/page1",
    "https://example.com/page2",
    "https://example.com/page3"
  ],
  "formats": ["markdown"]
}
JSON
8) クロールステータスの確認
node .claude/skills/firecrawl-scraper/firecrawl-api.cjs crawl-status <crawl-id>

完了を待機:

node .claude/skills/firecrawl-scraper/firecrawl-api.cjs crawl-status <crawl-id> --wait

主な機能

形式
  • markdown:整形された markdown コンテンツ
  • html:解析済み HTML
  • rawHtml:元の HTML
  • links:ページ上のすべてのリンク
  • images:ページ上のすべての画像
  • summary:AI が生成した要約
  • json:スキーマに基づく構造化データの抽出
  • screenshot:ページのスクリーンショット(PNG)
コンテンツの制御
  • onlyMainContent:メインコンテンツのみを抽出します(デフォルト:true)
  • includeTags:含める CSS セレクター
  • excludeTags:除外する CSS セレクター
  • waitFor:スクレイピング前の待機時間(ms)
  • maxAge:キャッシュの有効期間(デフォルト:48 hours)
アクション(ブラウザーの自動化)
  • wait:指定した時間だけ待機します
  • click:セレクターで指定した要素をクリックします
  • write:フィールドにテキストを入力します
  • press:キーボードのキーを押します
  • scroll:ページをスクロールします
  • executeJavascript:カスタム JS を実行します
クロールオプション
  • includePaths:含める正規表現パターン
  • excludePaths:除外する正規表現パターン
  • maxDiscoveryDepth:クロールの最大深度
  • limit:クロールするページの最大数
  • allowExternalLinks:外部リンクをたどります
  • allowSubdomains:サブドメインをたどります

環境変数と API キー

API キーの設定方法は 2 つあります(優先順位:環境変数 > .env)。

  1. 環境変数:FIRECRAWL_API_KEY
  2. .env ファイル:.claude/skills/firecrawl-scraper/.env に配置します。.env.example からコピーできます

レスポンス形式

すべてのエンドポイントは、次の項目を含む JSON を返します。

  • success:成功したかどうかを示すブール値
  • data:抽出されたコンテンツ(形式はエンドポイントによって異なります)
  • crawl の場合:ジョブ ID を返します。ステータスを確認するには crawl-status(または GET /v2/crawl/{id})を使用します

コメント