chore: lint
This commit is contained in:
@@ -424,18 +424,14 @@ export default class Interpreter extends EventEmitter {
|
|||||||
// Wait a bit before next iteration to ensure content is loaded
|
// Wait a bit before next iteration to ensure content is loaded
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
|
|
||||||
// Check if new items were loaded
|
// Scrape the current page after scrolling/clicking
|
||||||
const newItemsLoaded = await page.evaluate((prevCount, listSelector) => {
|
const pageResults = await page.evaluate((cfg) => window.scrapeList(cfg), config);
|
||||||
const currentCount = document.querySelectorAll(listSelector).length;
|
allResults = allResults.concat(pageResults);
|
||||||
return currentCount > prevCount;
|
|
||||||
}, allResults.length, config.listSelector);
|
|
||||||
|
|
||||||
if (!newItemsLoaded) {
|
if (config.limit && allResults.length >= config.limit) {
|
||||||
return allResults; // No new items, end pagination
|
allResults = allResults.slice(0, config.limit);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentPage++;
|
|
||||||
await page.waitForTimeout(1000); // Wait for page to load
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return allResults;
|
return allResults;
|
||||||
|
|||||||
Reference in New Issue
Block a user