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.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
Add isFinishedFunction logs
Ondra Urbanb3b4438ac973
diff --git a/src/basic_crawler.js b/src/basic_crawler.jsindex 29dbc29ba..1e9f6502d 100644--- a/src/basic_crawler.js+++ b/src/basic_crawler.js@@ -159,6 +159,8 @@ class BasicCrawler {const isMaxPagesExceeded = () => maxRequestsPerCrawl && maxRequestsPerCrawl <= this.handledRequestsCount;const { isFinishedFunction } = autoscaledPoolOptions;+ this.isFinishedFunction = isFinishedFunction || this._defaultIsFinishedFunction;+const basicCrawlerAutoscaledPoolConfiguration = {minConcurrency,maxConcurrency,@@ -173,11 +175,22 @@ class BasicCrawler {return this._isTaskReadyFunction();},isFinishedFunction: async () => {- if (isMaxPagesExceeded() || !this.isRunning) return true;+ if (!this.isRunning) return true;+ if (isMaxPagesExceeded()) {+ log.info('BasicCrawler: Crawler reached the max requests per crawl limit by crawling '+ + `${this.handledRequestsCount} requests and will shut down.`);+ return true;+ }- return isFinishedFunction- ? isFinishedFunction()- : this._defaultIsFinishedFunction();+ const isFinished = await this.isFinishedFunction();+ if (isFinished) {+ if (isFinishedFunction) {+ log.info('BasicCrawler: Crawler\'s custom isFinishedFunction() returned true, the Crawler will shut down.');+ } else {+ log.info('BasicCrawler: All the Crawler\'s storages are finished (empty and processed), the Crawler will shut down.');+ }+ }+ return isFinished;},};