Parsing options.
The resulting document node.
Event emitter The defined events on documents including:
Raised then parser encounters a <script> element.
If this event has listeners, parsing will be suspended once it is emitted.
So, if <script> has the src attribute, you can fetch it, execute and then resume parsing just like browsers do.
The script element that caused the event.
Write additional html at the current parsing position. Suitable for implementing the DOM document.write and document.writeln methods.
HTML to write.
Resumes parsing.
WritableStream events
Generated using TypeDoc
Streaming HTML parser with scripting support. A writable stream.
NOTE: This API is available only for Node.js.
const parse5 = require('parse5'); const http = require('http'); // Fetch the page content and obtain it's <head> node http.get('http://inikulin.github.io/parse5/', res => { const parser = new parse5.ParserStream(); parser.once('finish', () => { console.log(parser.document.childNodes[1].childNodes[0].tagName); //> 'head' }); res.pipe(parser); });