Update to latest cheerio module

This commit is contained in:
Nick O'Leary
2021-06-08 09:31:27 +01:00
parent e9e64f6a44
commit dbbdd3f799
4 changed files with 161 additions and 96 deletions

View File

@@ -32,7 +32,7 @@ module.exports = function(RED) {
var tag = node.tag;
if (msg.hasOwnProperty("select")) { tag = node.tag || msg.select; }
try {
var $ = cheerio.load(value);
var $ = cheerio.load(value,null,false);
var pay = [];
var count = 0;
$(tag).each(function() {
@@ -42,9 +42,11 @@ module.exports = function(RED) {
$(tag).each(function() {
if (node.as === "multi") {
var pay2 = null;
if (node.ret === "html") { pay2 = cheerio.load($(this).html().trim()).xml(); }
if (node.ret === "html") { pay2 = cheerio.load($(this).html().trim(),null,false).xml(); }
if (node.ret === "text") { pay2 = $(this).text(); }
if (node.ret === "attr") { pay2 = this.attribs; }
if (node.ret === "attr") {
pay2 = Object.assign({},this.attribs);
}
//if (node.ret === "val") { pay2 = $(this).val(); }
/* istanbul ignore else */
if (pay2) {
@@ -61,9 +63,12 @@ module.exports = function(RED) {
}
}
if (node.as === "single") {
if (node.ret === "html") { pay.push( cheerio.load($(this).html().trim()).xml() ); }
if (node.ret === "html") { pay.push( cheerio.load($(this).html().trim(),null,false).xml() ); }
if (node.ret === "text") { pay.push( $(this).text() ); }
if (node.ret === "attr") { pay.push( this.attribs ); }
if (node.ret === "attr") {
var attribs = Object.assign({},this.attribs);
pay.push( attribs );
}
//if (node.ret === "val") { pay.push( $(this).val() ); }
}
index++;

View File

@@ -19,7 +19,7 @@
"acorn-walk": "8.1.0",
"ajv": "8.5.0",
"body-parser": "1.19.0",
"cheerio": "0.22.0",
"cheerio": "^1.0.0-rc.9",
"content-type": "1.0.4",
"cookie-parser": "1.4.5",
"cookie": "0.4.1",