feat: handle next click pagination on server
This commit is contained in:
@@ -394,17 +394,15 @@ export default class Interpreter extends EventEmitter {
|
|||||||
case 'clickNext':
|
case 'clickNext':
|
||||||
const nextButton = await page.$(config.pagination.selector);
|
const nextButton = await page.$(config.pagination.selector);
|
||||||
if (!nextButton) {
|
if (!nextButton) {
|
||||||
return allResults;
|
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(),
|
||||||
await Promise.all([
|
page.waitForNavigation({ waitUntil: 'networkidle' })
|
||||||
nextButton.click(),
|
]);
|
||||||
page.waitForNavigation({ waitUntil: 'load' }) // Wait for page navigation
|
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