You must login to use this action: subscribe.

Clear message

Rss Feed Parser

  1. copy/paste this code in a RssFeeder.py in your plugin/ directory
  2. 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>"

Rss Feed Parser (last edited 2009-08-15 23:47:17 by localhost)

Hosting sponsored by Netgate and Init Seven AG