Cheerio 数据扩散混乱

问题描述

一个这样的链接列表。想要使用cheerio/JQuery 选择器获取数据键的值。 1个链接

<a href="#" class="ui-btn.stuff.stuff2" data-diffusion-decimal="1.9090" >xxx</a>

试过这个:

$("a.ui-btn.stuff.stuff2").each(function(i,r) {
            const decimal = $(r).data("diffusionDecimal");
}

获取未定义的小数。

解决方法

应该是:

$("a.ui-btn.stuff.stuff2").each(function(i,a) {
  const decimal = parseFloat($(a).attr("data-diffusion-decimal"))
}

我不确定那个课程,你可能需要a[class="ui-btn.stuff.stuff2"]