const cheerio = require('cheerio'); const $ = cheerio.load(html); // your html
//如果有多少script腳本標簽使用循環來獲取
$('script').map(function(i, el) {
// 建議這里打印$(this) 因為this的對象可能不同
//因為存在script標簽為空的數據, 所以判斷children長度是否大於0
console.log("ffffffffff", $(this)[0].children[0])
//如果要獲取script標簽的屬性, 例如 type
console.log($(this)[0].attribs['type'])
});