Skip to content

Commit 4ed4a18

Browse files
committed
Adding a RSS parser block.
1 parent a08135a commit 4ed4a18

File tree

3 files changed

+548
-0
lines changed

3 files changed

+548
-0
lines changed

blocks/parse-rss/index.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const { Block } = require('node-webpipe')
2+
const feedparser = require('feedparser-promised')
3+
4+
new Block()
5+
.name('Parse RSS')
6+
.description('Parse an RSS feed into a series of records.')
7+
.input('url', 'string', 'The URL for the RSS feed.')
8+
.output('entries', 'array', 'All entries from the RSS feed')
9+
.handle((inputs, cb) => {
10+
const outputs = []
11+
feedparser.parse(inputs.url).then(items => {
12+
console.log(items)
13+
items.forEach(item => {
14+
outputs.push({
15+
date: item.date,
16+
title: item.title,
17+
link: item.link
18+
})
19+
})
20+
cb(null, { entries: outputs })
21+
})
22+
})
23+
.listen()

0 commit comments

Comments
 (0)