/
test.js
37 lines (28 loc) · 1020 Bytes
/
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
// A quick sandbox to play around with the RSS feeds data.
const fs = require("fs");
const Parser = require("rss-parser");
const parser = new Parser();
const blogFeedUrl = "https://blog.bolajiayodeji.com/rss.xml";
const newsletterFeedUrl = "https://bawd.bolajiayodeji.com/feed";
async function testBlog() {
const feed = await parser.parseURL(blogFeedUrl);
fs.writeFile("hashnode.json", JSON.stringify(feed), function (err) {
if (err) return console.log(err);
console.log(`Succesfully generated ✅`);
});
feed.items.slice(0, 5).map((item) => {
console.log([item.title, item.link, item.pubDate]);
});
}
async function testNewsletter() {
const feed = await parser.parseURL(newsletterFeedUrl);
fs.writeFile("substack.json", JSON.stringify(feed), function (err) {
if (err) return console.log(err);
console.log(`Succesfully generated ✅`);
});
feed.items.slice(0, 5).map((item) => {
console.log([item.title, item.link, item.pubDate]);
});
}
testBlog();
testNewsletter();