无法在节点中创建第二个 cheerio / jquery 对象

Unable to create a second cheerio / jquery object in node

我正在尝试在解析原始对象后创建第二个 jquery 对象。 这是我的代码的精简版

let tPage = ""
const $ = cheerio.load(pageHTML)
const iPage = $('body')

iPage.find('*').each(function() {
   <!- doing stuff -->
   tPage += '<+++ some html code added to the tPage string +++>'
}

const $abc = cheerio.load(tPage)
console.log(typeof $abc)

我需要将 tPage 转换回 jquery 对象,因为我需要对其进行进一步的处理。 但是 typeof $abc 一直说它是一个函数而不是一个对象。所以我不能使用 jQuery 方法来操作它。

我做错了什么? 提前致谢。

经过一番折腾,我用这个解决了这个问题:

let tPage = ""
const $ = cheerio.load(pageHTML)
const iPage = $('body')

iPage.find('*').each(function() {
   <!- doing stuff -->
   tPage += '<+++ some html code added to the tPage string +++>'
}

const abc = $(tPage)

并在末尾提取HTML:

console.log($.html(abc))