http://www.dalkescientific.com/Python/PyRSS2Gen.html
PyRSS2Gen
@route("/feeds/gen_news_top20_rss.html")
def gen_rss_feeds():
import PyRSS2Gen
articles=Article.query.order_by("id desc").limit(20).all()
article_rss_items=[]
for article in articles:
_link="http://www.15-1688.com/news/"+gen_article_link(article)
#_link=_link.decode("utf8").encode("gbk")
article_rss_item=PyRSS2Gen.RSSItem(
#title =article.title.encode("gbk"),
title =article.title,
link = _link,
description = article.content.encode("utf8"),
guid = PyRSS2Gen.Guid(_link),
pubDate = article.datetime)
article_rss_items.append(article_rss_item)
rss = PyRSS2Gen.RSS2(
#title = u"资讯".encode("gbk"),
title = "",
link = "",
description = "",
lastBuildDate = datetime.now(),
items =article_rss_items)
import codecs
f=codecs.open("./feeds/news.xml","w")
#f.write(codecs.BOM_UTF8)
rss.write_xml(f,encoding="utf-8")
return u'<script type="text/javascript">alert("生成rss feed生成!");window.location.href="/article/list.html";</script>'