fix: spacing
This commit is contained in:
@@ -448,7 +448,6 @@ export default class Interpreter extends EventEmitter {
|
|||||||
break;
|
break;
|
||||||
case 'clickLoadMore':
|
case 'clickLoadMore':
|
||||||
while (true) {
|
while (true) {
|
||||||
// Find and click the 'Load More' button
|
|
||||||
const loadMoreButton = await page.$(config.pagination.selector);
|
const loadMoreButton = await page.$(config.pagination.selector);
|
||||||
if (!loadMoreButton) {
|
if (!loadMoreButton) {
|
||||||
// No more "Load More" button, so scrape the remaining items
|
// No more "Load More" button, so scrape the remaining items
|
||||||
@@ -456,15 +455,12 @@ export default class Interpreter extends EventEmitter {
|
|||||||
allResults = allResults.concat(finalResults);
|
allResults = allResults.concat(finalResults);
|
||||||
return allResults;
|
return allResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Click the 'Load More' button to load additional items
|
// Click the 'Load More' button to load additional items
|
||||||
await loadMoreButton.click();
|
await loadMoreButton.click();
|
||||||
await page.waitForTimeout(2000); // Wait for new items to load
|
await page.waitForTimeout(2000); // Wait for new items to load
|
||||||
|
|
||||||
// After clicking 'Load More', scroll down to load more items
|
// After clicking 'Load More', scroll down to load more items
|
||||||
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
|
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
|
||||||
await page.waitForTimeout(2000);
|
await page.waitForTimeout(2000);
|
||||||
|
|
||||||
// Check if more items are available
|
// Check if more items are available
|
||||||
const currentHeight = await page.evaluate(() => document.body.scrollHeight);
|
const currentHeight = await page.evaluate(() => document.body.scrollHeight);
|
||||||
if (currentHeight === previousHeight) {
|
if (currentHeight === previousHeight) {
|
||||||
@@ -473,9 +469,7 @@ export default class Interpreter extends EventEmitter {
|
|||||||
allResults = allResults.concat(finalResults);
|
allResults = allResults.concat(finalResults);
|
||||||
return allResults;
|
return allResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
previousHeight = currentHeight;
|
previousHeight = currentHeight;
|
||||||
|
|
||||||
if (config.limit && allResults.length >= config.limit) {
|
if (config.limit && allResults.length >= config.limit) {
|
||||||
// If limit is set and reached, return the limited results
|
// If limit is set and reached, return the limited results
|
||||||
allResults = allResults.slice(0, config.limit);
|
allResults = allResults.slice(0, config.limit);
|
||||||
|
|||||||
Reference in New Issue
Block a user