feat: handle next click pagination on server
This commit is contained in:
@@ -394,15 +394,13 @@ export default class Interpreter extends EventEmitter {
|
||||
case 'clickNext':
|
||||
const nextButton = await page.$(config.pagination.selector);
|
||||
if (!nextButton) {
|
||||
const finalResults = await page.evaluate((cfg) => window.scrapeList(cfg), config);
|
||||
allResults = allResults.concat(finalResults);
|
||||
return allResults;
|
||||
}
|
||||
|
||||
// Capture the current URL to check if it changes after clicking next
|
||||
const currentURL = page.url();
|
||||
|
||||
await Promise.all([
|
||||
nextButton.click(),
|
||||
page.waitForNavigation({ waitUntil: 'load' }) // Wait for page navigation
|
||||
page.waitForNavigation({ waitUntil: 'networkidle' })
|
||||
]);
|
||||
break;
|
||||
case 'clickLoadMore':
|
||||
|
||||
Reference in New Issue
Block a user