Skip to content

Commit

Permalink
fix: spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
amhsirak committed Sep 20, 2024
1 parent fb6ce10 commit a7a1e9b
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions maxun-core/src/interpret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,23 +448,19 @@ export default class Interpreter extends EventEmitter {
break;
case 'clickLoadMore':
while (true) {
// Find and click the 'Load More' button
const loadMoreButton = await page.$(config.pagination.selector);
if (!loadMoreButton) {
// No more "Load More" button, so scrape the remaining items
const finalResults = await page.evaluate((cfg) => window.scrapeList(cfg), config);
allResults = allResults.concat(finalResults);
return allResults;
}

// Click the 'Load More' button to load additional items
await loadMoreButton.click();
await page.waitForTimeout(2000); // Wait for new items to load

// After clicking 'Load More', scroll down to load more items
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
await page.waitForTimeout(2000);

// Check if more items are available
const currentHeight = await page.evaluate(() => document.body.scrollHeight);
if (currentHeight === previousHeight) {
Expand All @@ -473,9 +469,7 @@ export default class Interpreter extends EventEmitter {
allResults = allResults.concat(finalResults);
return allResults;
}

previousHeight = currentHeight;

if (config.limit && allResults.length >= config.limit) {
// If limit is set and reached, return the limited results
allResults = allResults.slice(0, config.limit);
Expand Down

0 comments on commit a7a1e9b

Please sign in to comment.