メインコンテンツへスキップ

前提条件

SDKをインストール

npm install @mendable/firecrawl-js

環境変数

apiKey を直接渡す代わりに、FIRECRAWL_API_KEY 環境変数を設定してください。
export FIRECRAWL_API_KEY=fc-YOUR-API-KEY
const app = new Firecrawl();

Webを検索

import Firecrawl from '@mendable/firecrawl-js';

const app = new Firecrawl({ apiKey: "fc-YOUR-API-KEY" });
const results = await app.search("firecrawl web scraping", { limit: 5 });

for (const result of results.web) {
  console.log(result.title, result.url);
}

ページのスクレイピング

const result = await app.scrape("https://example.com");

console.log(result.markdown);
{
  "markdown": "# Example Domain\n\nThis domain is for use in illustrative examples...",
  "metadata": {
    "title": "Example Domain",
    "sourceURL": "https://example.com"
  }
}

ページを Interact で操作する

Interact を使うと、実行中のブラウザセッションを操作して、ボタンのクリック、フォームへの入力、動的コンテンツの抽出を行えます。
const result = await app.scrape('https://www.amazon.com', { formats: ['markdown'] });
const scrapeId = result.metadata?.scrapeId;

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

await app.stopInteraction(scrapeId);

次のステップ

スクレイピング ドキュメント

フォーマット、アクション、プロキシなど、スクレイピングのオプションをすべて掲載

Search ドキュメント

Web を検索してページ全体のコンテンツを取得

Interact ドキュメント

クリックやフォーム入力を通じて、動的コンテンツを抽出

Node SDK リファレンス

クロール、map、バッチスクレイピングなどを含む完全なSDKリファレンス