From 3771de92caca28e4ed95ccccfda8f7339b4a06d5 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 18 Aug 2024 22:19:06 +0530 Subject: [PATCH] feat: make previousHeight global --- maxun-core/src/interpret.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maxun-core/src/interpret.ts b/maxun-core/src/interpret.ts index ca273ac1..7c3c08d4 100644 --- a/maxun-core/src/interpret.ts +++ b/maxun-core/src/interpret.ts @@ -367,6 +367,7 @@ export default class Interpreter extends EventEmitter { private async handlePagination(page: Page, config: { listSelector: string, fields: any, limit?: number, pagination: any }) { let allResults: Record[] = []; let currentPage = 1; + let previousHeight = 0 while (true) { // Scrape current page @@ -380,7 +381,6 @@ export default class Interpreter extends EventEmitter { switch (config.pagination.type) { case 'scrollDown': - let previousHeight = 0 await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight)); // Wait for potential lazy-loaded content await page.waitForTimeout(2000);