我想获取html标签的行号。使用cheerios解析html时我发现如果使用{withStartIndices:true},则得到的行不是,但我使用的版本是“ @ types / cheerio”:“ ^ 0.22.17”,“ cheerio”:“ ^ 1.0.0-rc.3”
这是我的代码::
// const $ = load(htmlPage, { xmlMode: true, withStartIndices : true }); getting error withStartIndices that not a property
const $ = load(htmlPage, { xmlMode: true });
$('b').each((index, el) => {
const text: string = $(el).contents().first().text();
if (text.toLowerCase().includes('data:')) {
bottomInfo.isExist = true;
bottomInfo.lineNo = $(el).get(0);
/* already tried
bottomInfo.lineNo = $(el).get(0).startIndex;
bottomInfo.lineNo = $(el).startIndex;
*/
}
});
我如何获得电话号码
[几个小时后,我只是检查withStartIndices:true不适用于打字稿“ @ types / cheerio”:“ ^ 0.22.17”我直接使用“ cheerio”:“ ^ 1.0.0-rc.3”即可对我来说很好