Dja*_*ous 2 python django rss django-templates feedparser
请参阅此博客:http://johnsmallman.wordpress.com/author/johnsmallman/feed/
我想为我的应用程序获取RSS提要.上面的博客是一个wordpress博客.
我在用 feedparser
import feedparser
feeds = feedparser.parse('http://johnsmallman.wordpress.com/author/johnsmallman/feed/')
Run Code Online (Sandbox Code Playgroud)
现在feeds['feed']['title']
输出u"Johnsmallman's Blog \xbb John Smallman"
我的问题是我在我的应用程序中如何呈现这一点.让我们说这篇博客包含了100篇文章.所以我想循环并获取所有数据.
这样做有没有直接的方法?任何预定义的库或方法?
我有谷歌用谷歌搜索但很难过.
我基本上希望将它呈现给Django Template.所以真的会对它有所了解.
需要指导的人:)
如果您添加feeds
到模板上下文,您应该能够在模板中循环它:
<ul>
{% for entry in feeds.entries %}
<li><a href="{{entry.link}}">{{entry.title}}</a></li>
{% endfor %}
</ul>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3474 次 |
最近记录: |