How to generate RSS 2.0 feed quickly using Python

last updated in Categories Howto, Python

How to generate RSS 2.0 feeds in Python.001
I wanted to generate RSS 2.0 feeds in Python. Nothing fancy but for certain tasks I needed it something that is quick and just works out of the box. I found rfeed – a library to generate RSS 2.0 feeds in Python. It is in my opinion straightforward to use.


First clone the repo, run:
$ git clone
Sample outputs:

Cloning into 'rfeed'...
remote: Counting objects: 213, done.
remote: Total 213 (delta 0), reused 0 (delta 0), pack-reused 213
Receiving objects: 100% (213/213), 40.81 KiB | 0 bytes/s, done.
Resolving deltas: 100% (136/136), done.
Checking connectivity... done.

The library is a single file, so you could simply copy it wherever you need it. You can also install it using the following command:
$ cd rfeed/
$ python install

Sample outputs:

running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying -> build/lib.linux-x86_64-2.7
running install_lib
copying build/lib.linux-x86_64-2.7/ -> /usr/local/lib/python2.7/dist-packages
byte-compiling /usr/local/lib/python2.7/dist-packages/ to rfeed.pyc
running install_egg_info
Removing /usr/local/lib/python2.7/dist-packages/rfeed-1.0.0.egg-info
Writing /usr/local/lib/python2.7/dist-packages/rfeed-1.0.0.egg-info


Let us create a file named
$ vi
Append the following text into it:

import datetime
from rfeed import *
# year, month, date, hh, mm, ss
item1 = Item(
        title = "My 10 UNIX Command Line Mistakes",
        link = "",
        description = "Here are a few mistakes that I made while working at UNIX/Linux prompt.",
    author = "Vivek Gite",
    guid = Guid(""),
        pubDate = datetime.datetime(2017, 8, 01, 4, 0))
item2 = Item(
        title = "Top 25 Nginx Web Server Best Security Practices",
        link = "",
        description = "Best Nginx web server hardening and security practice for Linux/Unix sysadmins and developers.",
    author = "Vivek Gite",
    guid = Guid(""),
        pubDate = datetime.datetime(2017, 8, 01, 4, 2))
feed = Feed(
        title = "nixCraft Updated Tutorials/Posts",
        link = "",
        description = "nixCraft Linux and Unix Sysadmin Blog - Recently updated posts",
        language = "en-US",
        lastBuildDate =,
        items = [item1, item2])
print feed.rss()


  1. The main object of the RSS 2.0 feed is the Feed class.
  2. The Feed class supports a list of Item instances.
  3. To specify the guid attribute of an item, you can use a Guid instance.
  4. Item: Represents an item of a feed’s channel.
  5. To get the final RSS content, you can use the rss() method of the Feed class.

Just run it:
$ python
$ python > /var/www/nfs/atom/updated.xml
For more info see rfeed on github.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.