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
Añade tu clave de API a .env:
FIRECRAWL_API_KEY=fc-YOUR-API-KEY
Crea un servicio de Firecrawl
Crea src/firecrawl/firecrawl.service.ts:
import { Injectable } from "@nestjs/common";
import Firecrawl from "@mendable/firecrawl-js";
@Injectable()
export class FirecrawlService {
private readonly client: Firecrawl;
constructor() {
this.client = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });
}
async search(query: string, limit = 5) {
return this.client.search(query, { limit });
}
async scrape(url: string) {
return this.client.scrape(url);
}
async interact(url: string, prompts: string[]) {
const result = await this.client.scrape(url, { formats: ['markdown'] });
const scrapeId = result.metadata?.scrapeId;
const responses = [];
for (const prompt of prompts) {
const response = await this.client.interact(scrapeId, { prompt });
responses.push(response);
}
await this.client.stopInteraction(scrapeId);
return responses;
}
}
Crea src/firecrawl/firecrawl.controller.ts:
import { Body, Controller, Post } from "@nestjs/common";
import { FirecrawlService } from "./firecrawl.service";
@Controller("firecrawl")
export class FirecrawlController {
constructor(private readonly firecrawlService: FirecrawlService) {}
@Post("search")
async search(@Body("query") query: string) {
return this.firecrawlService.search(query);
}
@Post("scrape")
async scrape(@Body("url") url: string) {
return this.firecrawlService.scrape(url);
}
@Post("interact")
async interact(@Body("url") url: string, @Body("prompts") prompts: string[]) {
return this.firecrawlService.interact(url, prompts);
}
}
Crea src/firecrawl/firecrawl.module.ts:
import { Module } from "@nestjs/common";
import { FirecrawlService } from "./firecrawl.service";
import { FirecrawlController } from "./firecrawl.controller";
@Module({
providers: [FirecrawlService],
controllers: [FirecrawlController],
exports: [FirecrawlService],
})
export class FirecrawlModule {}
Importa FirecrawlModule en tu AppModule.
curl -X POST http://localhost:3000/firecrawl/search \
-H "Content-Type: application/json" \
-d '{"query": "firecrawl web scraping"}'
Documentación de scraping
Todas las opciones de scraping, incluidos formatos, acciones y proxies
Documentación de búsqueda
Buscar en la web y obtener el contenido completo de la página
Documentación de Interact
Haz clic, rellena formularios y extrae contenido dinámico
Referencia del SDK de Node
Referencia completa del SDK con rastreo, mapeo, extracción por lotes y más