1 | const cheerio = require('cheerio');
|
2 |
|
3 | const htmlParser = {};
|
4 |
|
5 | /**
|
6 | * Get items from html content.
|
7 | * @param content
|
8 | * @param selectors
|
9 | */
|
10 | htmlParser.getItems = function (content, selectors,callback) {
|
11 | var $ = cheerio.load(content);
|
12 | if(typeof callback==='function'){
|
13 | $(selectors).each(function(i,e){
|
14 | callback($,i,e);
|
15 | });
|
16 | }
|
17 | }
|
18 | module.exports=htmlParser; |
\ | No newline at end of file |