chore: lint
This commit is contained in:
@@ -394,27 +394,27 @@ export default class Interpreter extends EventEmitter {
|
|||||||
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 items that have already been scraped
|
// filter out items that have already been scraped
|
||||||
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;
|
if (scrapedItems.has(uniqueKey)) return false;
|
||||||
scrapedItems.add(uniqueKey);
|
scrapedItems.add(uniqueKey);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
allResults = allResults.concat(newResults);
|
allResults = allResults.concat(newResults);
|
||||||
// if the limit is reached, return the required number of items
|
// if the limit is reached, return the required number of items
|
||||||
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;
|
return allResults;
|
||||||
}
|
}
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
nextButton.click(),
|
nextButton.click(),
|
||||||
page.waitForNavigation({ waitUntil: 'networkidle' })
|
page.waitForNavigation({ waitUntil: 'networkidle' })
|
||||||
]);
|
]);
|
||||||
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