0
v-firecrawl/apps/js-sdk/example.js

22 lines
642 B
JavaScript
Raw Normal View History

2024-05-23 10:47:04 -04:00
import { v4 as uuidv4 } from 'uuid';
2024-04-16 12:31:16 -04:00
import FirecrawlApp from '@mendable/firecrawl-js';
2024-04-16 10:38:22 -04:00
const app = new FirecrawlApp({apiKey: "YOUR_API_KEY"});
2024-05-23 10:47:04 -04:00
const idempotencyKey = uuidv4(); // optional
const crawlResult = await app.crawlUrl('mendable.ai', {crawlerOptions: {excludes: ['blog/*'], limit: 5}}, false, 2, idempotencyKey);
2024-04-16 10:38:22 -04:00
console.log(crawlResult)
const jobId = await crawlResult['jobId'];
console.log(jobId);
let job;
while (true) {
job = await app.checkCrawlStatus(jobId);
if (job.status == 'completed') {
break;
}
await new Promise(resolve => setTimeout(resolve, 1000)); // wait 1 second
}
console.log(job.data[0].content);