0

This is my code I'm using cheerio

const url = 'https://kbdfans.com/collections/ready-to-use'
axios(url).then(response => {
    const html = response.data
    const $ = cheerio.load(html)

    const arrayData = []
    $('.product-block.one-fifth.small-down--one-whole.grid-flex__item').each(function(index){
        const description = $(this).find('a.product-block__title-link').text()
        const price = $(this).find('span.theme-money').text()
        const img = $(this).find('img.rimage__image.fade-in.lazyautosizes.lazyloaded').attr('srcset')
        const id = index
        arrayData.push({
            id,
            description,
            price,
            img
        })
    })
    const result = {
        arrayData
        }
         console.log(arrayData)
}).catch(err => {console.log(err)})   

This is the image that I want to obtain.

nullptr
  • 3,701
  • 2
  • 16
  • 40
  • `srcset` isn't in view-source, the static HTML that `axios` gets you. That data is added dynamically with JS. You can try using Puppeteer or find the API in the network tab. See [How can I scrape pages with dynamic content using node.js?](https://stackoverflow.com/questions/28739098/how-can-i-scrape-pages-with-dynamic-content-using-node-js) – ggorlen Sep 07 '22 at 00:09
  • Does this answer your question? [How can I scrape pages with dynamic content using node.js?](https://stackoverflow.com/questions/28739098/how-can-i-scrape-pages-with-dynamic-content-using-node-js) – ggorlen Jan 01 '23 at 07:12

0 Answers0