Answer the question
In order to leave comments, you need to log in
How to download all images with NodeJS/Puppeteer?
I use Puppeteer to download images from a website. Now everything works, but only with one izorbazhenie. How can I make it so that all images inside a given div are downloaded?
let imagefile = await page.evaluate(async () => {
let imagefile
try {
imagefile = document.querySelector('div.item-wrapper img').src
} catch(e) {
imagefile = null
}
return imagefile
})
var imagefileDL = await page.goto(imagefile);
fs.writeFile('./uploads/' + imagefile.replace(/^.*[\\\/]/, ''), await imagefileDL.buffer(), function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question