> ## Documentation Index
> Fetch the complete documentation index at: https://firecrawl-claude-eager-dijkstra-u6tgua.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub のスクレイピング

> Firecrawl のコア機能と Research Index を使って GitHub をスクレイピング・検索する方法

Firecrawl のコア機能を使って、GitHub のリポジトリ、Issue、ドキュメントをスクレイピングする方法を説明します。

<Info>
  Firecrawl で GitHub のデータを取得する方法は 2 つあります。特定の `github.com` URL を**スクレイピング、マッピング、またはクロール**する方法 (このページでは以降こちらを説明します) と、[Research Index](/ja/features/research) の GitHub 検索を使って、正確な URL がわからなくても GitHub 全体から関連する Issue、プルリクエスト、ディスカッション、README を意味的に探し出す方法です。
</Info>

<div id="setup">
  ## セットアップ
</div>

```bash theme={null}
npm install firecrawl zod
```

<div id="scrape-with-json-mode">
  ## JSONモードでスクレイピング
</div>

Zod スキーマを使ってリポジトリから構造化データを抽出します。

```typescript theme={null}
import { Firecrawl } from 'firecrawl';
import { z } from 'zod';

const firecrawl = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });

const result = await firecrawl.scrape('https://github.com/firecrawl/firecrawl', {
    formats: [{
        type: 'json',
        schema: z.object({
            name: z.string(),
            description: z.string(),
            stars: z.number(),
            forks: z.number(),
            language: z.string(),
            topics: z.array(z.string())
        })
    }]
});

console.log(result.json);
```

<div id="search">
  ## Search
</div>

GitHub 上のリポジトリ、Issue、ドキュメントを検索します。

```typescript theme={null}
import { Firecrawl } from 'firecrawl';

const firecrawl = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });

const searchResult = await firecrawl.search('machine learning site:github.com', {
    limit: 10,
    sources: [{ type: 'web' }], // { type: 'news' }, { type: 'images' }
    scrapeOptions: {
        formats: ['markdown']
    }
});

console.log(searchResult);
```

<div id="search-github-with-the-research-index">
  ## Research Index で GitHub を検索
</div>

Firecrawl の [Research Index](/ja/features/research) には GitHub インデックスが含まれており、インデックス化された公開 GitHub Issue、プルリクエスト、ディスカッション、リポジトリの README を意味検索できます。正確なリポジトリや URL がわからない場合に、実装の詳細やエンジニアリング上の先行事例を探すのに役立ちます。

```typescript theme={null}
import { Firecrawl } from 'firecrawl';

const firecrawl = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });

const results = await firecrawl.research.searchGithub(
    'how to handle rate limit retries with exponential backoff',
    { k: 10 }
);

console.log(results);
```

汎用の[`/search`](/ja/features/search)エンドポイントでも、`github`カテゴリを指定すれば、同じGitHubインデックスにアクセスできます。

```typescript theme={null}
import { Firecrawl } from 'firecrawl';

const firecrawl = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });

const searchResult = await firecrawl.search('exponential backoff retry', {
    categories: ['github'],
    limit: 10
});

console.log(searchResult);
```

Python、cURL、CLI、MCPでの使用方法については、[Research Index ガイド](/ja/features/research)を参照してください。

<div id="scrape">
  ## Scrape
</div>

リポジトリ、Issue、またはファイルなど、1 つの GitHub ページをスクレイピングします。

```typescript theme={null}
import { Firecrawl } from 'firecrawl';

const firecrawl = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });

const result = await firecrawl.scrape('https://github.com/firecrawl/firecrawl', {
    formats: ['markdown'] // 例: html, links など
});

console.log(result);
```

<div id="map">
  ## Map
</div>

リポジトリやドキュメントサイト内に存在するすべての利用可能な URL を列挙します。注記: Map はコンテンツを含まない URL のみを返します。

```typescript theme={null}
import { Firecrawl } from 'firecrawl';

const firecrawl = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });

const mapResult = await firecrawl.map('https://github.com/vercel/next.js/tree/canary/docs');

console.log(mapResult.links);
// コンテンツなしのURLの配列を返す
```

<div id="crawl">
  ## Crawl
</div>

リポジトリやドキュメント内の複数ページをクロールします。

```typescript theme={null}
import { Firecrawl } from 'firecrawl';

const firecrawl = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });

const crawlResult = await firecrawl.crawl('https://github.com/facebook/react/wiki', {
    limit: 10,
    scrapeOptions: {
        formats: ['markdown']
    }
});

console.log(crawlResult.data);
```

<div id="batch-scrape">
  ## バッチスクレイプ
</div>

複数の GitHub URL を一括でスクレイプします。

```typescript theme={null}
import { Firecrawl } from 'firecrawl';

const firecrawl = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });

// 完了を待機
const job = await firecrawl.batchScrape([
    'https://github.com/vercel/next.js',
    'https://github.com/facebook/react',
    'https://github.com/microsoft/typescript'],
    {
        options: {
            formats: ['markdown']
        },
        pollInterval: 2,
        timeout: 120
    }
);


console.log(job.status, job.completed, job.total);

console.log(job);
```

<div id="batch-scrape-with-json-mode">
  ## JSONモードでのバッチスクレイプ
</div>

複数のリポジトリから構造化データを一括で抽出します。

```typescript theme={null}
import { Firecrawl } from 'firecrawl';
import { z } from 'zod';

const firecrawl = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });

// 完了を待機
const job = await firecrawl.batchScrape([
    'https://github.com/vercel/next.js',
    'https://github.com/facebook/react'],
    {
        options: {
            formats: [{
                type: 'json',
                schema: z.object({
                    name: z.string(),
                    description: z.string(),
                    stars: z.number(),
                    language: z.string()
                })
            }]
        },
        pollInterval: 2,
        timeout: 120
    }
);


console.log(job.status, job.completed, job.total);

console.log(job);
```
