How to use the htmlparser.Parser function in htmlparser

To help you get started, we’ve selected a few htmlparser 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 fb55 / htmlparser2 / tests / bench.js View on Github external
function HtmlParser() {
        var handler = new htmlparser.DefaultHandler();
        var parser = new htmlparser.Parser(handler);
        this.parse = function(s) {
            parser.parseComplete(s);
        };
    }
github macacajs / NoSmoke / lib / crawler / web.js View on Github external
NSCrawler.prototype.beforeExplore = function(source) {
  let raw = source.value.replace(/\n|\r|\\n/gi, '');
  let that = this;
  let handler = new htmlparser.DefaultHandler(function(error, dom) {
    if (error) {
      console.log('parsing error: ' + error);
    } else {
      let target = dom[dom.length - 1].children[dom[dom.length - 1].children.length - 1];
      source.value = target;
      that.explore(source);
    }
  });
  let parser = new htmlparser.Parser(handler);
  parser.parseComplete(raw);
};
github thallium205 / BitcoinVisualizer / client.old / node_modules / jquery / node_modules / htmlparser / tmp / snippet.js View on Github external
var sys = require("sys");
var htmlparser = require("htmlparser");

var html = "<p>foo</p>";

var handler = new htmlparser.DefaultHandler(function(err, dom) {
	if (err)
		sys.debug("Error: " + err);
	else
		sys.debug(sys.inspect(dom, false, null));
}, { enforceEmptyTags: true });
var parser = new htmlparser.Parser(handler);
parser.parseComplete(html);
github sinnerschrader / schlump / src / validator.js View on Github external
function parseHtml(html) {
	const handler = new htmlparser.DefaultHandler(() => undefined);
	const parser = new htmlparser.Parser(handler);
	parser.parseComplete(html);
	return handler.dom;
}
github daffl / breezy / lib / parser.js View on Github external
exports.parse = function(html, options) {
  var handler = new htmlparser.DefaultHandler(function() {}, options);
  var parser = new htmlparser.Parser(handler);

  parser.parseComplete(html.toString());

  var dom = handler.dom;

  _.each(dom, convert);

  return dom;
};

htmlparser

Forgiving HTML/XML/RSS Parser in JS for *both* Node and Browsers

MIT
Latest version published 11 years ago

Package Health Score

53 / 100
Full package analysis

Popular htmlparser functions

Similar packages