Merge pull request #876 from getmaxun/pag-limiter
fix(maxun-core): run stuck in endless loop of clicking on pagination buttons
This commit is contained in:
@@ -1246,9 +1246,9 @@ export default class Interpreter extends EventEmitter {
|
||||
if (checkLimit()) return allResults;
|
||||
|
||||
let loadMoreCounter = 0;
|
||||
// let previousResultCount = allResults.length;
|
||||
// let noNewItemsCounter = 0;
|
||||
// const MAX_NO_NEW_ITEMS = 2;
|
||||
let previousResultCount = allResults.length;
|
||||
let noNewItemsCounter = 0;
|
||||
const MAX_NO_NEW_ITEMS = 5;
|
||||
|
||||
while (true) {
|
||||
if (this.isAborted) {
|
||||
@@ -1332,21 +1332,21 @@ export default class Interpreter extends EventEmitter {
|
||||
|
||||
await scrapeCurrentPage();
|
||||
|
||||
// const currentResultCount = allResults.length;
|
||||
// const newItemsAdded = currentResultCount > previousResultCount;
|
||||
const currentResultCount = allResults.length;
|
||||
const newItemsAdded = currentResultCount > previousResultCount;
|
||||
|
||||
// if (!newItemsAdded) {
|
||||
// noNewItemsCounter++;
|
||||
// debugLog(`No new items added after click (${noNewItemsCounter}/${MAX_NO_NEW_ITEMS})`);
|
||||
if (!newItemsAdded) {
|
||||
noNewItemsCounter++;
|
||||
debugLog(`No new items added after click (${noNewItemsCounter}/${MAX_NO_NEW_ITEMS})`);
|
||||
|
||||
// if (noNewItemsCounter >= MAX_NO_NEW_ITEMS) {
|
||||
// debugLog(`Stopping after ${MAX_NO_NEW_ITEMS} clicks with no new items`);
|
||||
// return allResults;
|
||||
// }
|
||||
// } else {
|
||||
// noNewItemsCounter = 0;
|
||||
// previousResultCount = currentResultCount;
|
||||
// }
|
||||
if (noNewItemsCounter >= MAX_NO_NEW_ITEMS) {
|
||||
debugLog(`Stopping after ${MAX_NO_NEW_ITEMS} clicks with no new items`);
|
||||
return allResults;
|
||||
}
|
||||
} else {
|
||||
noNewItemsCounter = 0;
|
||||
previousResultCount = currentResultCount;
|
||||
}
|
||||
|
||||
if (checkLimit()) return allResults;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user