-
Notifications
You must be signed in to change notification settings - Fork 9
/
test.js
51 lines (49 loc) · 1.51 KB
/
test.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var extractor = require('./index');
var fs = require('fs');
var path = require('path');
var async = require('async');
var articlesToParse = [
{
url: 'http://gizmodo.com/watch-a-single-day-on-the-london-tube-in-two-minutes-1692810056',
filename: 'gizmodo'
},
{
url: 'http://www.wired.com/2015/03/google-android-broken-wifi/',
filename: 'wired'
},
{
url: 'http://techcrunch.com/2015/03/20/from-the-8200-to-silicon-valley/',
filename: 'techcrunch'
},
{
url: 'http://paulgraham.com/altair.html',
filename: 'paulgraham'
},
{
url: 'http://www.economist.com/news/united-states/21646763-when-lethal-injection-gets-tricky-try-guns-or-gas-drugs-dont-work',
filename: 'the-economist'
},
{
url: 'http://onstartups.com/insider-look-at-hubspot-sidekick-growth-approach',
filename: 'on-startups'
},
{
url: 'http://www.smashingmagazine.com/2015/03/20/better-browser-input-events/',
filename: 'smashing-magazine'
},
{
url: 'http://nextviewventures.com/blog/pretotyping-product-market-fit-google-alberto-savoia/',
filename: 'next-view-ventures'
}
];
async.each(articlesToParse, function (articleToParse, parseCallback) {
extractor.extractData(articleToParse.url, function (err, data) {
console.log('Parsed article:', data.title);
console.log(data.summary);
console.log('-----');
fs.writeFileSync(path.join(process.cwd(), 'data/' + articleToParse.filename + '.html'), data.content);
parseCallback();
});
}, function () {
process.exit(0);
});