> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firecrawl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHubのスクレイピング

> Firecrawlのコア機能でGitHubをスクレイピングする方法

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

<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="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);
```
