How to use the cheerio.default.load function in cheerio

To help you get started, we’ve selected a few cheerio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frexy / svg-sprite-generator / src / source / sprite.js View on Github external
fs.readFile(file, function (err, data) {
                if (err) {
                    return rej(err);

                // data
                let q = cheerio.load(data.toString("utf8"), {
                    xmlMode: true

                let symbols = q("symbol");

                if (symbols.length == 0) {
                    return res([]);
                let eles = [];
                symbols.each(function (index, ele) {
                    let t = q(this);
                        id: t.attr("id"),
                        viewBox: t.attr("viewBox"),
                        content: t.html()