Configuration
.env :
Remarque : Si vous utilisez Node < 20, installezdotenvet ajoutezimport 'dotenv/config'à votre code.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Utilisez Firecrawl avec Gemini de Google pour le scraping web et des workflows d’IA
npm install @mendable/firecrawl-js @google/genai
.env :
FIRECRAWL_API_KEY=votre_clé_firecrawl
GEMINI_API_KEY=votre_clé_gemini
Remarque : Si vous utilisez Node < 20, installezdotenvet ajoutezimport 'dotenv/config'à votre code.
import FirecrawlApp from '@mendable/firecrawl-js';
import { GoogleGenAI } from '@google/genai';
const firecrawl = new FirecrawlApp({ apiKey: process.env.FIRECRAWL_API_KEY });
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
const scrapeResult = await firecrawl.scrape('https://firecrawl.dev', {
formats: ['markdown']
});
console.log('Scraped content length:', scrapeResult.markdown?.length);
const response = await ai.models.generateContent({
model: 'gemini-2.5-flash',
contents: `Summarize: ${scrapeResult.markdown}`,
});
console.log('Summary:', response.text);
import FirecrawlApp from '@mendable/firecrawl-js';
import { GoogleGenAI } from '@google/genai';
const firecrawl = new FirecrawlApp({ apiKey: process.env.FIRECRAWL_API_KEY });
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
const scrapeResult = await firecrawl.scrape('https://news.ycombinator.com/', {
formats: ['markdown']
});
console.log('Scraped content length:', scrapeResult.markdown?.length);
const chat = ai.chats.create({
model: 'gemini-2.5-flash'
});
// Demander les 3 premières stories sur Hacker News
const result1 = await chat.sendMessage({
message: `D'après le contenu de ce site web Hacker News, quelles sont les 3 premières stories en ce moment ?\n\n${scrapeResult.markdown}`
});
console.log('Top 3 Stories:', result1.text);
// Demander les 4ème et 5ème stories sur Hacker News
const result2 = await chat.sendMessage({
message: `Maintenant, quelles sont les 4ème et 5ème stories principales sur Hacker News d'après le même contenu ?`
});
console.log('4th and 5th Stories:', result2.text);
import FirecrawlApp from '@mendable/firecrawl-js';
import { GoogleGenAI, Type } from '@google/genai';
const firecrawl = new FirecrawlApp({ apiKey: process.env.FIRECRAWL_API_KEY });
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
const scrapeResult = await firecrawl.scrape('https://stripe.com', {
formats: ['markdown']
});
console.log('Longueur du contenu extrait :', scrapeResult.markdown?.length);
const response = await ai.models.generateContent({
model: 'gemini-2.5-flash',
contents: `Extraire les informations de l'entreprise : ${scrapeResult.markdown}`,
config: {
responseMimeType: 'application/json',
responseSchema: {
type: Type.OBJECT,
properties: {
name: { type: Type.STRING },
industry: { type: Type.STRING },
description: { type: Type.STRING },
products: {
type: Type.ARRAY,
items: { type: Type.STRING }
}
},
propertyOrdering: ['name', 'industry', 'description', 'products']
}
}
});
console.log('Informations de l'entreprise extraites :', response?.text);
