小编bos*_*lee的帖子

如何使用Cheerio js删除<div>和<br>?

我有以下html,我想通过Cheerios解析.

    var $ = cheerio.load('<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>This works well.</div><div><br clear="none"/></div><div>So I have been doing this for several hours. How come the space does not split? Thinking that this could be an issue.</div><div>Testing next paragraph.</div><div><br clear="none"/></div><div>Im testing with another post. This post should work.</div><div><br clear="none"/></div><h1>This is for test server.</h1></body></html>', {
    normalizeWhitespace: true,
});

// trying to parse the html
// the goals are to 
// 1. remove all the 'div'
// 2. clean up …
Run Code Online (Sandbox Code Playgroud)

javascript node.js cheerio

7
推荐指数
1
解决办法
9525
查看次数

标签 统计

cheerio ×1

javascript ×1

node.js ×1