Documentation Index
Fetch the complete documentation index at: https://firecrawl-mog-search-exclude-include-domains.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
npm install @mendable/firecrawl-js
.env に API key を追加してください:
FIRECRAWL_API_KEY=fc-YOUR-API-KEY
server/api/search.post.ts を作成します:
import Firecrawl from "@mendable/firecrawl-js";
const firecrawl = new Firecrawl({
apiKey: process.env.FIRECRAWL_API_KEY,
});
export default defineEventHandler(async (event) => {
const { query } = await readBody(event);
const results = await firecrawl.search(query, { limit: 5 });
return results;
});
Vue コンポーネントから呼び出します。
<script setup>
const query = ref("");
const { data, execute } = useFetch("/api/search", {
method: "POST",
body: { query },
immediate: false,
});
</script>
<template>
<div>
<input v-model="query" placeholder="ウェブを検索..." />
<button @click="execute()">検索</button>
<ul v-if="data?.web">
<li v-for="result in data.web" :key="result.url">
<a :href="result.url">{{ result.title }}</a>
</li>
</ul>
</div>
</template>
server/api/scrape.post.ts を作成します:
import Firecrawl from "@mendable/firecrawl-js";
const firecrawl = new Firecrawl({
apiKey: process.env.FIRECRAWL_API_KEY,
});
export default defineEventHandler(async (event) => {
const { url } = await readBody(event);
const result = await firecrawl.scrape(url);
return result;
});
Vue コンポーネントから呼び出す:
<script setup>
const url = ref("https://example.com");
const { data, execute } = useFetch("/api/scrape", {
method: "POST",
body: { url },
immediate: false,
});
</script>
<template>
<div>
<input v-model="url" placeholder="URLを入力" />
<button @click="execute()">スクレイピング</button>
<pre v-if="data">{{ data.markdown }}</pre>
</div>
</template>
server/api/interact.post.ts を作成します:
import Firecrawl from "@mendable/firecrawl-js";
const firecrawl = new Firecrawl({
apiKey: process.env.FIRECRAWL_API_KEY,
});
export default defineEventHandler(async (event) => {
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",
});
await firecrawl.stopInteraction(scrapeId);
return { output: response.output };
});
スクレイピングのドキュメント
フォーマット、アクション、プロキシを含む、すべてのスクレイピングのオプション
検索 ドキュメント
Web を検索してページ全体のコンテンツを取得
Interact ドキュメント
クリック、フォーム入力、動的コンテンツの抽出
Node SDK リファレンス
クロール、map、バッチスクレイプなどを含む SDK リファレンス