If it won't be simple, it simply won't be. [Hire me, source code] by Miki Tebeka, CEO, 353Solutions

Thursday, April 03, 2008

FeedMe - A simple web-based RSS reader

A simple web-based RSS reader in less than 100 lines of code.

Using feedparser, jQuery and plain old CGI.


<title>FeedMe - A Minimal Web Based RSS Reader</title>
<link rel="stylesheet" type="text/css" href="feedme.css" />
<link rel="shortcut icon" href="feedme.ico" />
a {
text-decoration: none;
a:hover {
background-color: silver;
div.summary {
display: none;
position: absolute;
background: gray;
width: 70%;
font 18px monospace;
border: 1px solid black;
<h2>FeedMe - A Minimal Web Based RSS Reader</h2>
Feed URL: <input type="text" size="80" id="feed_url"/>
<button onclick="refresh_feed();">Load</button>
<hr />
<div id="items">
<script src="jquery.js"></script>
function refresh_feed() {
var url = $.trim($("#feed_url").val());
if ("" == url) {

$("#items").load("feed.cgi", {"url" : url});
/* Update every minute */
setTimeout("refresh_feed();", 1000 * 60);


#!/usr/bin/env python

import feedparser
from cgi import FieldStorage, escape
from time import ctime

<a href="%(link)s"
</a> <br />
<div class="summary" id="%(eid)s">

def main():
print "Content-type: text/html\n"

form = FieldStorage()
url = form.getvalue("url", "")
if not url:
raise SystemExit("error: not url given")

feed = feedparser.parse(url)
for enum, entry in enumerate(feed.entries):
entry.eid = "entry%d" % enum
html = ENTRY_TEMPLATE % entry
print html
except Exception, e:
# FIXME: Log errors

print "<br />%s" % ctime()

if __name__ == "__main__":

How it works:

  • The JavaScript script call loads the output of feed.cgi to the items div
  • feed.cgi reads the RSS feed from the given URL and output an HTML fragment
  • Hovering over a title will show the entry summary
  • setTimeout makes sure we refresh the view every minute

No comments:

Blog Archive