Image of current source: Here
Current code:
let imageArr = []
$('.plink image').each(function(){
let image = $(this).attr('src')
imageArr.push(image)
})
console.log(imageArr)
Log nothing , why so?
Image of current source: Here
Current code:
let imageArr = []
$('.plink image').each(function(){
let image = $(this).attr('src')
imageArr.push(image)
})
console.log(imageArr)
Log nothing , why so?
Don't has tag image
, it is img
.
Use .plink.image img
instead of .plink image
.
const $ = cheerio.load(body, {
xmlMode: true // to load noscript
})
let imageArr = []
$('.plink.image img').each(function(a, b) {
let image = $(this).attr('src')
if (image && !image.match(/white.jpg$/)) { // remove template image
imageArr.push(image)
}
})
console.log(imageArr)