鍍金池/ 問答/PHP  網(wǎng)絡(luò)安全  HTML/ cheerio中文轉(zhuǎn)碼參數(shù)如何添加?別人代碼中直接傳入.pip(cheerio(

cheerio中文轉(zhuǎn)碼參數(shù)如何添加?別人代碼中直接傳入.pip(cheerio(function($) 實在是看不懂

我下載了一個壓縮html的插件
轉(zhuǎn)換后中文變得不可閱讀
我找到了解決方式為添加參數(shù)
cheerio.load(html,{decodeEntities: false});
但是問題在于 別人的代碼
是直接.pip(cheerio(function($)
這樣的嵌套 不知道這種情況下cheerio.load方法如何使用了
在下實新手.在是看不懂了.
而且不知道從何查起了.
自己折騰半天 實在是無解
所以只好來提問求助.
希望前輩們指點一下
非常感謝

gulp.task('indexHtml', function() { 
    return gulp.src('index.html') 
        .pipe(cheerio(function ($) { 
            $('script').remove(); 
            $('link').remove(); 
            $('body').append('<script src="skin/zhuce/MergeMin/app.full.min.js"></script>'); 
            $('head').append('<link rel="stylesheet" href="skin/zhuce/MergeMin/app.full.min.css">'); 
        })) 
        .pipe(gulp.dest('test/')); 
});
回答
編輯回答
真難過

看代碼應(yīng)該是用的gulp-cheerio
解決方法:

     .pipe(cheerio({
            run: function ($,file) {
                $('script').remove(); 
                $('link').remove(); 
                $('body').append('<script src="skin/zhuce/MergeMin/app.full.min.js"></script>'); 
                $('head').append('<link rel="stylesheet" href="skin/zhuce/MergeMin/app.full.min.css">');
            },
            parserOptions: {
                decodeEntities: false //不轉(zhuǎn)義
            }
        }
        ))
2017年9月26日 00:52