chore: remove comments

This commit is contained in:
karishmas6
2024-08-20 23:15:21 +05:30
parent 24a3dd9a97
commit 6b6583647a

View File

@@ -394,7 +394,6 @@ export default class Interpreter extends EventEmitter {
case 'scrollUp': case 'scrollUp':
break; break;
case 'clickNext': case 'clickNext':
// Scrape the current page
const pageResults = await page.evaluate((cfg) => window.scrapeList(cfg), config); const pageResults = await page.evaluate((cfg) => window.scrapeList(cfg), config);
// Filter out already scraped items // Filter out already scraped items
@@ -407,31 +406,31 @@ export default class Interpreter extends EventEmitter {
allResults = allResults.concat(newResults); allResults = allResults.concat(newResults);
// Stop if limit is reached
if (config.limit && allResults.length >= config.limit) { if (config.limit && allResults.length >= config.limit) {
return allResults.slice(0, config.limit); return allResults.slice(0, config.limit);
} }
// Move to the next page
const nextButton = await page.$(config.pagination.selector); const nextButton = await page.$(config.pagination.selector);
if (!nextButton) { if (!nextButton) {
return allResults; // No more pages to scrape return allResults; // No more pages to scrape
} }
// Click the "Next" button and wait for the next page to load
await Promise.all([ await Promise.all([
nextButton.click(), nextButton.click(),
page.waitForNavigation({ waitUntil: 'networkidle' }) page.waitForNavigation({ waitUntil: 'networkidle' })
]); ]);
// Wait a bit for the content to load
await page.waitForTimeout(1000); await page.waitForTimeout(1000);
break; break;
case 'clickLoadMore': case 'clickLoadMore':
const loadMoreButton = await page.$(config.pagination.selector); const loadMoreButton = await page.$(config.pagination.selector);
if (!loadMoreButton) { if (!loadMoreButton) {
return allResults; // No more items to load return allResults;
} }
await loadMoreButton.click(); await loadMoreButton.click();
break; break;