-
Notifications
You must be signed in to change notification settings - Fork 22
/
example.js
45 lines (40 loc) · 1.38 KB
/
example.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
/**********************************************************************
example.js
Example of the node-rss feed parser
**********************************************************************/
var sys = require('sys');
var rss = require('./node-rss');
/**********************************************************************
Example One:
Getting a remote RSS feed and parsing
rss.parseURL(feed_url, use_excerpt, callback);
**********************************************************************/
// URL of the feed you want to parse
var feed_url = 'http://feeds.feedburner.com/github';
var response = rss.parseURL(feed_url, function(articles) {
sys.puts(articles.length);
for(i=0; i<articles.length; i++) {
sys.puts("Article: "+i+", "+
articles[i].title+"\n"+
articles[i].link+"\n"+
articles[i].description+"\n"+
articles[i].content
);
}
});
/**********************************************************************
Example Two:
Getting a local RSS feed and parsing
rss.parseFile(feed_file, use_excerpt, callback);
**********************************************************************/
var response = rss.parseFile('nodeblogs.com.feed.xml', function(articles) {
sys.puts(articles.length);
for(i=0; i<articles.length; i++) {
sys.puts("Article: "+i+", "+
articles[i].title+"\n"+
articles[i].link+"\n"+
articles[i].description+"\n"+
articles[i].content
);
}
});