mirror of
https://github.com/mendableai/firecrawl.git
synced 2024-11-16 11:42:24 +08:00
20 lines
547 B
JavaScript
20 lines
547 B
JavaScript
|
import { FirecrawlApp } from '@mendableai/firecrawl-js';
|
||
|
|
||
|
const app = new FirecrawlApp({apiKey: "YOUR_API_KEY"});
|
||
|
|
||
|
const crawlResult = await app.crawlUrl('mendable.ai', {crawlerOptions: {excludes: ['blog/*'], limit: 5}}, false);
|
||
|
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);
|