-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
24 lines (21 loc) · 814 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var request = require('request');
var url = require('url');
var cleaner = require('./lib/cleaner');
var author = require('./lib/parser/author');
var content = require('./lib/parser/content');
var title = require('./lib/parser/title');
var summary = require('./lib/parser/summary');
module.exports = {
extractData: function (articleUrl, callback) {
request(articleUrl, function (err, response, body) {
var data = {};
var preppedHtml = cleaner.prepForParsing(body);
data.domain = url.parse(articleUrl).host;
data.author = author.getAuthor(preppedHtml);
data.title = title.getTitle(preppedHtml);
data.content = content.getArticleContent(preppedHtml, data.host);
data.summary = summary.getSummary(preppedHtml, data.content);
callback(null, data);
});
}
}