云盘
志元云盘
备份云盘
Home
/
志元云盘
/
webdav
/
sync
/
c
/
vue-modbus
/
modbus-project
/
node_modules
/
domhandler
File
OriginalPic
Thumbnails
CopyAllDownloadUrl
EditTime
Size
lib
2024-08-13 05:39:26
36.84 KB
LICENSE
2024-07-14 16:19:01
1.23 KB
package.json
2024-07-14 16:19:01
1.46 KB
readme.md
2024-07-14 16:19:01
4.01 KB
# domhandler [](https://travis-ci.com/fb55/domhandler) The DOM handler creates a tree containing all nodes of a page. The tree can be manipulated using the [domutils](https://github.com/fb55/domutils) or [cheerio](https://github.com/cheeriojs/cheerio) libraries and rendered using [dom-serializer](https://github.com/cheeriojs/dom-serializer) . ## Usage ```javascript const handler = new DomHandler([
callback(err, dom), ] [
options ]); // const parser = new Parser(handler[, options]); ``` Available options are described below. ## Example ```javascript const { Parser } = require("htmlparser2"); const { DomHandler } = require("domhandler"); const rawHtml = "Xyz "; const handler = new DomHandler((error, dom) => { if (error) { // Handle error } else { // Parsing completed, do something console.log(dom); } }); const parser = new Parser(handler); parser.write(rawHtml); parser.end(); ``` Output: ```javascript [ { data: "Xyz ", type: "text", }, { type: "script", name: "script", attribs: { language: "javascript", }, children: [ { data: "var foo = '
';<", type: "text", }, ], }, { data: "