I am trying to get links from a page and then navigate to the next page through a click of a button. The issue is I first need to add all the links on the first page to a queue however the enqueueList function seems to start a new page, causing a "Node not found error" when I try to click on an element. Any advice would be helpful!
exports.handleList = async ({ request, page }, requestQueue) => {
await Apify.utils.enqueueLinks({
page: page,
requestQueue: requestQueue,
selector: "#traziPoduzeca > tbody > tr > td > span > a",
baseUrl: "https://www.fininfo.hr/Poduzece/[.*]",
transformRequestFunction: (request) => {
request.userData = {
label: "DETAIL",
};
return request;
},
});
log.info('about to scrap urls')
await page.waitForTimeout(120);
let btn_selector =
"//div[@class='contentNav'][1]//div[@class='pagination'][1]//span[@class='current']/following-sibling::a";
let buttonEle = await page.$x(btn_selector);
log.info(`length of pagination is ${buttonEle.length}`);
for (let index = 0; index < buttonEle.length; index++) {
await page.waitForTimeout(120);
await buttonEle[index].click();
log.info("clicked");
await page.waitForTimeout(200);
await Apify.utils.enqueueLinks({
page: page,
requestQueue: requestQueue,
selector: "#traziPoduzeca > tbody > tr > td > span > a",
baseUrl: "https://www.fininfo.hr/Poduzece/[.*]",
transformRequestFunction: (request) => {
request.userData = {
label: "DETAIL",
};
return request;
},
});
}
};