> ## 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.

# Deno Deploy

> Deno Deploy で Firecrawl を使って、エッジでWebデータの検索、スクレイピング、操作を行えます。

<div id="prerequisites">
  ## 前提条件
</div>

* Deno 1.40+ または Deno 2
* Firecrawl APIキー — [無料で取得できます](https://www.firecrawl.dev/app/api-keys)

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

`main.ts` を作成します。

```typescript theme={null}
import Firecrawl from "npm:firecrawl";

const firecrawl = new Firecrawl({
  apiKey: Deno.env.get("FIRECRAWL_API_KEY"),
});
```

<div id="search-the-web">
  ## Webを検索
</div>

Webを検索し、ページ全文を含む結果を返す `/search` ルートを追加します。

```typescript theme={null}
Deno.serve(async (req) => {
  const url = new URL(req.url);

  if (req.method === "POST" && url.pathname === "/search") {
    const { query } = await req.json();
    const results = await firecrawl.search(query, { limit: 5 });
    return Response.json(results);
  }

  return new Response("Not found", { status: 404 });
});
```

<div id="scrape-a-page">
  ## ページをスクレイピングする
</div>

任意のURLからクリーンなMarkdownを抽出するため、`/scrape` ルートを追加します。

```typescript theme={null}
if (req.method === "POST" && url.pathname === "/scrape") {
  const { url: targetUrl } = await req.json();
  const result = await firecrawl.scrape(targetUrl);
  return Response.json(result);
}
```

<div id="interact-with-a-page">
  ## ページをInteractする
</div>

`/interact` ルートを追加すると、実行中のブラウザセッションをInteractできます。ボタンのクリック、フォームへの入力、動的コンテンツの抽出が可能です。

```typescript theme={null}
if (req.method === "POST" && url.pathname === "/interact") {
  const result = await firecrawl.scrape("https://www.amazon.com", {
    formats: ["markdown"],
  });
  const scrapeId = result.metadata?.scrapeId;

  await firecrawl.interact(scrapeId, {
    prompt: "Search for iPhone 16 Pro Max",
  });
  const response = await firecrawl.interact(scrapeId, {
    prompt: "Click on the first result and tell me the price",
  });
  console.log(response.output);

  await firecrawl.stopInteraction(scrapeId);
  return Response.json({ output: response.output });
}
```

<div id="run-locally">
  ## ローカルで実行
</div>

```bash theme={null}
FIRECRAWL_API_KEY=fc-YOUR-API-KEY deno run --allow-net --allow-env main.ts
```

<div id="deploy">
  ## デプロイ
</div>

Deno Deploy CLI (`deployctl`) をインストールして、デプロイします。

```bash theme={null}
deployctl deploy --project=my-scraper main.ts
```

Deno Deploy のダッシュボードまたは CLI で環境変数を設定します。

```bash theme={null}
deployctl env set FIRECRAWL_API_KEY=fc-YOUR-API-KEY --project=my-scraper
```

<div id="test-it">
  ## 試す
</div>

```bash theme={null}
curl -X POST https://my-scraper.deno.dev/search \
  -H "Content-Type: application/json" \
  -d '{"query": "firecrawl web scraping"}'
```

<div id="next-steps">
  ## 次のステップ
</div>

<CardGroup cols={2}>
  <Card title="Search のドキュメント" icon="magnifying-glass" href="/ja/features/search">
    Web を検索し、ページ全体のコンテンツを取得
  </Card>

  <Card title="スクレイピング のドキュメント" icon="file-lines" href="/ja/features/scrape">
    フォーマット、アクション、プロキシなど、すべてのスクレイピングのオプション
  </Card>

  <Card title="Interact のドキュメント" icon="hand-pointer" href="/ja/features/interact">
    クリック、フォーム入力、動的コンテンツの抽出
  </Card>

  <Card title="Node SDK リファレンス" icon="node" href="/ja/sdks/node">
    クロール、map、バッチスクレイプなどを含む SDK リファレンス
  </Card>
</CardGroup>
