RSS reader in Node.js

Introduction:

An RSS (Really Simple Syndication) feed is an online file that contains information about every piece of content a website has published. The information includes a summary, content, publication date, author, publisher name, link and other metadata. Almost every news website provides its RSS feed which can be integrated in other websites. Generally, an RSS Feed returns an XML file. In this article, we will see how to parse RSS feed. How to convert RSS Feed into javascript Object.

First we need to install a third-party library as following.

npm install rss-parser

Create a file named as demo.js and paste following code snippet in the file.

let Parser = require('rss-parser');
let parser = new Parser();


async function rssParser(){
 let feed = await parser.parseURL('https://www.reddit.com/.rss');
  console.log(feed.title);

  feed.items.forEach(item => {
    console.log(item.title + ':' + item.link)
  });

}
rssParser();

Let’s run the script by following command.

node demo.js

Now you can see the titles and links from the parsed RSS feed. Following is the sample output for the above RSS XML feed.

feedUrl: 'https://www.reddit.com/.rss'
title: 'reddit: the front page of the internet'
description: ""
link: 'https://www.reddit.com/'
items:
    - title: 'The water is too deep, so he improvises'
      link: 'https://www.reddit.com/r/funny/comments/3skxqc/the_water_is_too_deep_so_he_improvises/'
      pubDate: 'Thu, 12 Nov 2015 21:16:39 +0000'
      creator: "John Doe"
      content: '<a href="http://example.com">this is a link</a> &amp; <b>this is bold text</b>'
      contentSnippet: 'this is a link & this is bold text'
      guid: 'https://www.reddit.com/r/funny/comments/3skxqc/the_water_is_too_deep_so_he_improvises/'
      categories:
          - funny
      isoDate: '2015-11-12T21:16:39.000Z

Complete documentation of the library can be found at here. Let’s use this library and create your news scrapper or article scrapper tool. Thanks for reading. #Happy Coding #TopCode #topcode.in

#rss reader node js #rss nodejs #node js rss feed reader #rss parser nodejs #rss feed reader javascript #rss feed reader node js create rss reader javascript #build rss reader javascript #javascript rss reader jquery #javascript rss reader widget #rss feed reader javascript #rss reader javascript example #javascript rss feed reader example #rss reader in javascript #rss reader node js rss feed node js #create rss feed node js #rss feed to json node #node js rss feed generator #node js rss feed aggregator #rss nodejs #node js rss feed reader #parse rss feed node js #rss feed reader node js

, , , , , ,

Related posts

Latest posts

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Please disable your adblocker or whitelist this site!

How to whitelist website on AdBlocker?

How to whitelist website on AdBlocker?

  1. 1 Click on the AdBlock Plus icon on the top right corner of your browser
  2. 2 Click on "Enabled on this site" from the AdBlock Plus option
  3. 3 Refresh the page and start browsing the site