如何使用 CheerioJS 获取 shopmissa.com 的文章

How to get the articles of shopmissa.com using CheerioJS

我正在尝试获取此 post 的所有文章。 This is my webiste so far.

但是我不太会用Cheerio,我只会获取简单的元素
而且,例如,产品的 URL 图片有很多子元素。

我需要的数据是:

我开始尝试获取所有文章图片:

axios.get("https://www.shopmissa.com/collections/eye-shadow")
     .then(res => 
       { if(res.status == 200) 
         { const html = res.data; 
           const $ = cheerio.load(html); 
           $(".product-index").each((i, elem) => 
             { console.log($(this)
               .children(".prod-container")
               .children(".prod-image") 
               .find("a")
               .children("reveal")
               .find("img")
               .attr("src")
             ) 
           }
         ) 
       } 
     }, error => console.log(error)
   )

但我不了解全貌...
我能做什么?

不要试图专注于遍历每个 DOM,而是使用选择器让 cheerio 完成繁重的工作。

axios.get("https://www.shopmissa.com/collections/eye-shadow")
  .then(res => {
    if (res.status == 200) {
      const html = res.data;
      const $ = cheerio.load(html);
      $("#product-loop").children().each((i, elem) => {
        var imageSource = $(elem).find(".reveal img").attr("src")
        var productName = $(elem).find(".product-info h3").text()
        var productPrice = $(elem).find(".product-info .money").text()
        console.log(imageSource, productName, productPrice)
      })
    }
  }, error => console.log(error))