Cheerio 互动版

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

过滤

.first()

获取cheerio集合中的第一个cheerio对象。

$('#fruits').children().first().text(); //=> Apple

.last()

获取cheerio集合中的最后一个cheerio对象。

$('#fruits').children().last().text(); //=> Pear

.eq(i)

根据索引获取cheerio集合中的某一个对象。参数可以使负数,表示从尾部开始索引。

$('li').eq(0).text(); //=> Apple

$('li').eq(-1).text(); //=> Pear