#!/usr/bin/python from BeautifulSoup import BeautifulStoneSoup import urllib2 print "Content-type: text/html\n\n" #control variables start feedURL = "http://manningtreebenefice.blogspot.com/feeds/posts/default?alt=rss" numofposts = 5 #control variables end feed = urllib2.urlopen(feedURL) convertedfeed = feed.read().replace('','') convertedfeed = convertedfeed.replace('&','&') feedsoup = BeautifulStoneSoup(convertedfeed) itemlist = feedsoup.findAll('item') if len(itemlist) > numofposts: itemlist = itemlist[0:numofposts] for item in itemlist: print "

" print item.pubdate.string[0:16].encode('utf-8') print "

" post = item.description.string.replace('<','<') post = post.replace('>','>') post = post.replace('\n','
') print post.encode('utf-8')