From 8857de0b8fd99596fac74fd1f1b3d0de00e23aa1 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Tue, 20 Aug 2024 21:48:11 +0530 Subject: [PATCH] fix: remove while loop --- maxun-core/src/interpret.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/maxun-core/src/interpret.ts b/maxun-core/src/interpret.ts index 3316ad49..973211dc 100644 --- a/maxun-core/src/interpret.ts +++ b/maxun-core/src/interpret.ts @@ -374,7 +374,7 @@ export default class Interpreter extends EventEmitter { let previousHeight = 0; let currentPage = 1; // track unique items per page to avoid re-scraping - let scrapedItems: Set = new Set(); // Track unique items across all pages + let scrapedItems: Set = new Set(); while (true) { switch (config.pagination.type) { @@ -394,7 +394,6 @@ export default class Interpreter extends EventEmitter { case 'scrollUp': break; case 'clickNext': - while (true) { // Scrape the current page const pageResults = await page.evaluate((cfg) => window.scrapeList(cfg), config); @@ -425,9 +424,10 @@ export default class Interpreter extends EventEmitter { page.waitForNavigation({ waitUntil: 'networkidle' }) ]); - currentPage++; // Increment page count and proceed + // Wait a bit for the content to load + await page.waitForTimeout(1000); + break; - } case 'clickLoadMore': const loadMoreButton = await page.$(config.pagination.selector); if (!loadMoreButton) {