chore: lint
This commit is contained in:
@@ -393,40 +393,40 @@ export default class Interpreter extends EventEmitter {
|
|||||||
break;
|
break;
|
||||||
case 'scrollUp':
|
case 'scrollUp':
|
||||||
break;
|
break;
|
||||||
case 'clickNext':
|
case 'clickNext':
|
||||||
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
|
||||||
const newResults = pageResults.filter(item => {
|
const newResults = pageResults.filter(item => {
|
||||||
const uniqueKey = JSON.stringify(item);
|
const uniqueKey = JSON.stringify(item);
|
||||||
if (scrapedItems.has(uniqueKey)) return false; // Ignore if already scraped
|
if (scrapedItems.has(uniqueKey)) return false; // Ignore if already scraped
|
||||||
scrapedItems.add(uniqueKey); // Mark as scraped
|
scrapedItems.add(uniqueKey); // Mark as scraped
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
allResults = allResults.concat(newResults);
|
allResults = allResults.concat(newResults);
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
nextButton.click(),
|
nextButton.click(),
|
||||||
page.waitForNavigation({ waitUntil: 'networkidle' })
|
page.waitForNavigation({ waitUntil: 'networkidle' })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user