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.
- Node.js 18+、Bun 或 Deno
- Firecrawl API 密钥 — 免费获取
npm install hono @mendable/firecrawl-js
将你的 API 密钥添加到 .env 文件中:
FIRECRAWL_API_KEY=fc-YOUR-API-KEY
import { Hono } from "hono";
import Firecrawl from "@mendable/firecrawl-js";
const app = new Hono();
const firecrawl = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });
app.post("/search", async (c) => {
const { query } = await c.req.json();
const results = await firecrawl.search(query, { limit: 5 });
return c.json(results);
});
export default app;
app.post("/scrape", async (c) => {
const { url } = await c.req.json();
const result = await firecrawl.scrape(url);
return c.json(result);
});
使用 interact 控制实时浏览器会话,可点击按钮、填写表单并提取动态内容。
app.post("/interact", async (c) => {
const { url } = await c.req.json();
const result = await firecrawl.scrape(url, { 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 c.json({ output: response.output });
});
Hono 支持在多种运行时中运行。对于 Cloudflare Workers,请通过环境绑定传入 API 密钥:
import { Hono } from "hono";
import Firecrawl from "@mendable/firecrawl-js";
type Bindings = { FIRECRAWL_API_KEY: string };
const app = new Hono<{ Bindings: Bindings }>();
app.post("/search", async (c) => {
const firecrawl = new Firecrawl({ apiKey: c.env.FIRECRAWL_API_KEY });
const { query } = await c.req.json();
const results = await firecrawl.search(query, { limit: 5 });
return c.json(results);
});
export default app;
抓取文档
所有 抓取 选项,包括 formats、actions 和代理设置
Node SDK 参考
涵盖爬取、map、batch 抓取 等功能的完整 SDK 参考