Cheerio 互动版

过滤

.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