- copy/paste this code in a RssFeeder.py in your plugin/ directory
call the function in your page like [[RssFeeder(http://url.com/brol.rss)]]
import feedparser
Dependencies = []
def execute(macro, args):
url = args
feed = feedparser.parse(url )
if feed.has_key("channel"):
mylink = feed["channel"].get("link", "No link")
mytitle = feed["channel"].get("title", "No title")
output = "<h1><a href=\"" + mylink + "\">" + " Feed: " + mytitle + "</a></h1>"
else:
output = "<h1>" + feed.version + " Feed: No channel</h1>"
if feed.has_key("items"):
items = feed["items"]
output = output + "<ul>"
for item in items:
mytitle = item.get("title", "")
mysummary = item.get("summary", "")
mydate = item.get("date", "")
if item.has_key("link"):
output = output + "\n<li>" + mydate + " <a href=\""+ item["link"] + "\">"+ mytitle + "</a>"
else:
output = output + "\n<li>" + mytitle
output = output + "</li>"
else:
output = output + "\n<p>No items</p>"
return output + "</ul>"
