Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Improve Statistics a bit

Ondra Urban4db41dc35cfd
diff --git a/src/crawlers/basic_crawler.js b/src/crawlers/basic_crawler.js
index ab473a39c..b11984070 100644
--- a/src/crawlers/basic_crawler.js
+++ b/src/crawlers/basic_crawler.js
@@ -263,6 +263,8 @@ class BasicCrawler {
await this.isRunningPromise;
} finally {
this.stats.stopLogging();
+ const finalStats = this.stats.getCurrent();
+ log.info('Crawler final request statistics:', finalStats);
}
}
diff --git a/src/crawlers/statistics.js b/src/crawlers/statistics.js
index e83cfd09a..a29aef534 100644
--- a/src/crawlers/statistics.js
+++ b/src/crawlers/statistics.js
@@ -91,7 +91,7 @@ export default class Statistics {
const totalMinutes = totalMillis / 1000 / 60;
return {
- avgDurationMillis: (this.totalJobDurationMillis / this.finishedJobs) || Infinity,
+ avgDurationMillis: Math.round(this.totalJobDurationMillis / this.finishedJobs) || Infinity,
perMinute: Math.round(this.finishedJobs / totalMinutes),
finished: this.finishedJobs,
failed: this.failedJobs,