feat: make previousHeight global
This commit is contained in:
@@ -367,6 +367,7 @@ export default class Interpreter extends EventEmitter {
|
|||||||
private async handlePagination(page: Page, config: { listSelector: string, fields: any, limit?: number, pagination: any }) {
|
private async handlePagination(page: Page, config: { listSelector: string, fields: any, limit?: number, pagination: any }) {
|
||||||
let allResults: Record<string, any>[] = [];
|
let allResults: Record<string, any>[] = [];
|
||||||
let currentPage = 1;
|
let currentPage = 1;
|
||||||
|
let previousHeight = 0
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// Scrape current page
|
// Scrape current page
|
||||||
@@ -380,7 +381,6 @@ export default class Interpreter extends EventEmitter {
|
|||||||
|
|
||||||
switch (config.pagination.type) {
|
switch (config.pagination.type) {
|
||||||
case 'scrollDown':
|
case 'scrollDown':
|
||||||
let previousHeight = 0
|
|
||||||
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
|
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
|
||||||
// Wait for potential lazy-loaded content
|
// Wait for potential lazy-loaded content
|
||||||
await page.waitForTimeout(2000);
|
await page.waitForTimeout(2000);
|
||||||
|
|||||||
Reference in New Issue
Block a user