JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 220
  • Score
    100M100P100Q89055F

transform streaming html using css selectors

Package Exports

  • cornet

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cornet) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

##About

The cornet is a brass instrument very similar to the trumpet, distinguished by its conical bore, compact shape, and mellower tone quality. - Wikipedia

This project is demonstrating how to use a couple of my libraries to replace substack/node-trumpet in just a couple of LOC.

Even better, there are some advantages over trumpet:

  • The ammount of usable CSS selectors is increased dramatically thanks to fb55/CSSselect.
  • cornet uses fb55/htmlparser2, which is probably the fastest HTML parser currently available for node. And it's much less strict than the sax module used by trumpet.
  • By using the great MatthewMueller/cheerio module, you can do everything with your document that would be possible with jQuery.

##Example

var Parser = require("htmlparser2").WritableStream,
    Cornet = require("cornet"),
    minreq = require("minreq"),
    $ = require("cheerio");

var cornet = new Cornet();

minreq.get("http://github.com/fb55").pipe(new Parser(cornet));

cornet.remove("script"); //remove all scripts

//show all repos
cornet.select(".repo_list", function(elem){
    $(elem).find("h3").each(function(i){
        console.log("repo %d: %s", i, $(this).text());
    });
});