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.
bun add @mendable/firecrawl-js
Adicione sua chave de API ao .env:
FIRECRAWL_API_KEY=fc-YOUR-API-KEY
Bun tem um servidor HTTP integrado. Crie index.ts:
import Firecrawl from "@mendable/firecrawl-js";
const firecrawl = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });
Bun.serve({
port: 3000,
async fetch(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 });
},
});
console.log("Server running on port 3000");
Execute:
Fazer scraping de uma página
Adicione uma rota /scrape ao mesmo servidor:
if (req.method === "POST" && url.pathname === "/scrape") {
const { url: targetUrl } = await req.json();
const result = await firecrawl.scrape(targetUrl);
return Response.json(result);
}
Use o interact para controlar uma sessão do navegador em tempo real — clique em botões, preencha formulários e extraia conteúdo dinâmico.
if (req.method === "POST" && url.pathname === "/interact") {
const { url: targetUrl } = await req.json();
const result = await firecrawl.scrape(targetUrl, { 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 Response.json({ output: response.output });
}
Use o Firecrawl em um script Bun independente:
import Firecrawl from "@mendable/firecrawl-js";
const app = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });
const results = await app.search("firecrawl web scraping", { limit: 5 });
console.log(results);
Documentação de scraping
Todas as opções de scraping, incluindo formatos, ações e proxies
Documentação de busca
Faça uma busca na web e obtenha o conteúdo completo da página
Documentação de interação
Clique, preencha formulários e extraia conteúdo dinâmico
Referência do SDK de Node
Referência completa do SDK, com rastreamento, map, extração em lote e muito mais