如何在cheerios中获得第no行?是否特定于版本

问题描述 投票:0回答:1

我想获取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;
      */
  }
 });

我如何获得电话号码

javascript jquery node.js cheerio
1个回答
0
投票

[几个小时后,我只是检查withStartIndices:true不适用于打字稿“ @ types / cheerio”:“ ^ 0.22.17”我直接使用“ cheerio”:“ ^ 1.0.0-rc.3”即可对我来说很好

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.