Blog

Home / Blog

A Guide to Building Your Own RSS Reader in R

Jason Li
Sr. Software Development Engineer
Skilled Angular and .NET developer, team leader for a healthcare insurance company.
Janaury 14, 2023


The RSS feed has been around since the late 1990s and is still one of the best ways to stay on top of multiple news sources. If you select the right feeds, your RSS reader will make it easy for you to scan headlines from various sources, keeping you up-to-date on what's new. Creating your own RSS feed reader in R is surprisingly simple. It is much more satisfying to program your own RSS reader, even though there are several good commercial and open-source RSS readers available.

What is RSS?

An RSS (Really Simple Syndication) feed is a web-based file that contains information about every piece of content published by a website. Each time a site publishes new content, details about that content are automatically generated in the file and displayed in reverse chronological order, including the full text of the subject matter or a summarization, date of publication, author, link, and so on.

The RSS feed keeps you updated on everything a site publishes, so you can use it to keep track of every new article published by your favorite blog or to create email newsletters and social media posts to promote your new content automatically. If you're used to staring at code all day, you can understand this just as quickly as reading formatted content on a website. But to the rest of us, this appears to be nonsense. You'll need an RSS reader to convert an RSS feed into something readable. RSS readers parse XML code and display it much like a website, based on the XML code of RSS feeds.

How to create your own RSS reader with R?

Create a Quarto or R script file

A plain R script can be used, but Quarto provides functional out-of-the-box styling. Quarto also makes it easier to use JavaScript for the final display if you prefer. However, the tutorial code also works fine in an R file. Unlike an R script, however, my Quarto document requires a YAML header to begin. Modify the YAML to create a single HTML file (embed-resources: true) and to hide my code (echo: false) as well as any code messages or warnings:

---

title: "Sharon's RSS Feed"

format:

html

embed-resources: true

editor: source

execute:

echo: false

warning: false

message: false

---

Load needed packages

Next, add some R code inside an R code block ("'r and "' enclose a block of executable code in Quarto; you don't need those if you're using a plain R script) and load the packages I'll need. tidyRSS is, as the name suggests, a library for reading RSS feeds into R.

``{r}

library(tidyRSS)

library(dplyr)

library(DT)

library(purrr)

library(stringr)

library(lubridate)

```

Add RSS feeds

Choosing relevant feeds is an integral part of having a beneficial RSS reader experience. I get mine from sources I like and then check websites or search for RSS feeds. As an optional exercise, you can use the rvest package to read sitemaps and convert them to RSS format, but that is beyond the scope of this tutorial.

You could save your feeds in a separate CSV or Excel file and import them into your app. This way, you won't have to touch the app code every time your feed list is updated. For the sake of clarity, I'll create a data frame in my script file with the feeds I want and their titles.

RSS feeds can be accessed using a pure R script and standard SQL on any machine that has R and Java installed. To work with remote RSS feeds in R, use the CData JDBC Driver for RSS and the RJDBC package. You can access your data in the popular, open-source R language using the CData Driver, written for industry-proven standards.

How to use RSS feeds

Maintain an eye out for new blog posts, podcasts, and YouTube channel uploads

RSS Feeds are a convenient way to keep up with your favorite websites, such as blogs and online magazines. If a website provides an RSS feed, you will be notified whenever a new post is published, and you will be able to read a summary or the entire post. Keeping up with what blogs—both in the industry work in and those write about—are publishing is a fantastic way to learn fresh stuff, come up with new ideas for subjects to write about, and find studies to link to in the posts to write.

Each advantage is obtained by subscribing to the blogs you follow in an RSS reader. Rather than needing to visit each publication's blog independently to see if new content has been accepted for publication, Feedly shows you all the new content from all blogs you care about in a single interface.

Receive and view email newsletters in your RSS reader

The jury is still out on whether inbox zero is beneficial or detrimental to productivity, but it is the only way to manage email. And, because you're obsessed with inbox zero, unsubscribe from every email newsletter you receive immediately. Some newsletters are interesting to read because the publishers only deliver new content through those newsletters. In Feedly, there is no corresponding blog post, podcast, or YouTube channel to follow; the only way to get the content is to sign up for the newsletter.

Destroy the Newsletter generates an email address that you can use to sign up for newsletters. Newsletters sent to that email address are automatically converted into an XML feed. Simply add the provided feed link to your RSS reader to access those newsletters.

View social media from important accounts

It is possible to generate an RSS feed for an account in RSS.app and subscribe to it in your RSS reader if you want to see everything that the company/person posts instead of what social media algorithms think you want to see.

Create email newsletters automatically

RSS is an excellent way to stay up to date on the latest content from your favorite publishers, but it also works well on the other side of the fence. If you're a publisher, you can build your email newsletters automatically by using an RSS feed for your blog, podcast, YouTube channel, social media profile, and so on.

For instance, if your email newsletter is a list of your most recent publication posts, complete with titles, links, and brief descriptions, you can push those details to your email newsletter tool via RSS, eliminating the need to copy and paste those details manually. Then, to streamline your newsletter creation process, you go in, add a subject line, select a list, and click Send. Another way publishers save time is to use RSS feed updates to post new content to their social media profiles instantly.

It may be common for you to share articles about your industry with colleagues or to post engaging content from other places on your social media account. You can automatically share what you're reading using these workflows without copying and pasting.

Monitor brand mentions in a feed

Alternatively, you can do the same thing for free using RSS feeds and a reader. A brand monitoring tool may require a monthly subscription fee, but that can also be done with RSS feeds and a reader.

If you have Google Alerts set up for your name or company name, you can have those alerts delivered to an RSS feed rather than your email account. Select the RSS feed in the Deliver field when creating your alert. Once the alert is set up, you can copy the link to your RSS reader and subscribe to the feed.

An RSS reader is an excellent option if you want to see everything your competitors are doing in one place. Using the procedure mentioned above, you can subscribe to your competitors' blogs and email newsletters, view all of their social media posts, and even set up Google Alerts for online mentions of their brands—all from within your RSS reader.

The benefits of using RSS feeds

As social media became more popular, RSS began to lose favor. However, there are better ways to stay updated on their new content than following brands and authors on social media. For example, some brands post links to new and old content every fifteen minutes. There is no guarantee that you will notice new content in your feed among the clutter.

Second, social media platforms rarely show you everything that the accounts you follow post. Instead, they use algorithms to determine what you want to see and then display that content first. You're usually out of luck if everything is all you want to see.

In contrast, RSS feeds deliver all the content published in reverse chronological order by the sites you follow. No algorithm decides what you want or doesn't want to see, no old content is thrown into the mix, and no content is repeated.

Conclusion

If you primarily want to see content that a large number of people like or converse with, social media is the best way to go. However, if you want to see the latest content from the sites and people you care about, RSS easily outperforms social media.