If you want to use jQuery selectors on the server to parse a bunch of HTML, I would recommend you to check out cheerio.

Installation

1
$ npm install cheerio

Examples

Given the following HTML:

1
2
3
4
5
<ol class="breadcrumb">
<li><a href="/home">Home</a></li>
<li><a href="/library">Library</a></li>
<li><a href="/data" class="active">Data</a></li>
</ol>
1
2
3
4
var cheerio = require('cheerio');
var $ = cheerio.load(htmlString);

$('ol .active').text(); // 'Data'
1
2
3
4
$('[href]').each(function getLink() {
var attr = $(this).attr('href');
// Do something with the link
});

Get the ol class

1
$('ol').attr('class'); // 'breadcrumb'



Check our more examples in the documentation