fix: add max no new items check
This commit is contained in:
@@ -1246,9 +1246,9 @@ export default class Interpreter extends EventEmitter {
|
|||||||
if (checkLimit()) return allResults;
|
if (checkLimit()) return allResults;
|
||||||
|
|
||||||
let loadMoreCounter = 0;
|
let loadMoreCounter = 0;
|
||||||
// let previousResultCount = allResults.length;
|
let previousResultCount = allResults.length;
|
||||||
// let noNewItemsCounter = 0;
|
let noNewItemsCounter = 0;
|
||||||
// const MAX_NO_NEW_ITEMS = 2;
|
const MAX_NO_NEW_ITEMS = 5;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (this.isAborted) {
|
if (this.isAborted) {
|
||||||
@@ -1332,21 +1332,21 @@ export default class Interpreter extends EventEmitter {
|
|||||||
|
|
||||||
await scrapeCurrentPage();
|
await scrapeCurrentPage();
|
||||||
|
|
||||||
// const currentResultCount = allResults.length;
|
const currentResultCount = allResults.length;
|
||||||
// const newItemsAdded = currentResultCount > previousResultCount;
|
const newItemsAdded = currentResultCount > previousResultCount;
|
||||||
|
|
||||||
// if (!newItemsAdded) {
|
if (!newItemsAdded) {
|
||||||
// noNewItemsCounter++;
|
noNewItemsCounter++;
|
||||||
// debugLog(`No new items added after click (${noNewItemsCounter}/${MAX_NO_NEW_ITEMS})`);
|
debugLog(`No new items added after click (${noNewItemsCounter}/${MAX_NO_NEW_ITEMS})`);
|
||||||
|
|
||||||
// if (noNewItemsCounter >= MAX_NO_NEW_ITEMS) {
|
if (noNewItemsCounter >= MAX_NO_NEW_ITEMS) {
|
||||||
// debugLog(`Stopping after ${MAX_NO_NEW_ITEMS} clicks with no new items`);
|
debugLog(`Stopping after ${MAX_NO_NEW_ITEMS} clicks with no new items`);
|
||||||
// return allResults;
|
return allResults;
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// noNewItemsCounter = 0;
|
noNewItemsCounter = 0;
|
||||||
// previousResultCount = currentResultCount;
|
previousResultCount = currentResultCount;
|
||||||
// }
|
}
|
||||||
|
|
||||||
if (checkLimit()) return allResults;
|
if (checkLimit()) return allResults;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user