I’m trying to scrape the website but I want to fetch the images on puppeteer and cheerio. I’m facing issues fetching images because the images changed on the click event
Website name: Work Wear Express
In the above URL, there is an image with the pagination and When I click on the pagination links the image source changes. so I want to click on the pagination links and scrape the images.
That’s My Code:
const productImage_Selector = "img.ProductGallery-galleryImage-20_"; //image selector
const productImages = $(productImage_Selector);
const elements = await page.$$('ul.ProductGallery-galleryThumbsList-3sE li'); //paginnation selector
console.log("length:", elements.length) //checking the length of paginations
for (let i = 0; i < elements.length; i++) {
console.log("loop start")
await elements[i].click();
await page.waitForTimeout(10000);
content = page.content();
await content.then(async success => {
$ = cheerio.load(success);
console.log("in load success")
console.log("loop index:", i);
console.log("check: ", productImages.length)
console.log("image: ", productImages.attribs['data-src'])
})
await page.evaluate(() => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});