问题
Refer this blog: http://johnsmallman.wordpress.com/author/johnsmallman/feed/
I want to fetch the RSS feed for my application. The above blog is a wordpress blog.
I am using feedparser
import feedparser
feeds = feedparser.parse('http://johnsmallman.wordpress.com/author/johnsmallman/feed/')
Now feeds['feed']['title']
Outputs u"Johnsmallman's Blog \xbb John Smallman"
My question is How exactly i present this in my app. Lets say this blog contains 100s of articles. So i want to loop over and fetch all data.
Isn't there any direct way of doing this? Any pre-defined library or method?
I have ofcouse googled but had hard time.
I am basically looking to render it to Django Template. So would really be looking something towards it.
Need guidance guys :)
回答1:
If you add feeds
to your template context, you should be able to loop through it in your template:
<ul>
{% for entry in feeds.entries %}
<li><a href="{{entry.link}}">{{entry.title}}</a></li>
{% endfor %}
</ul>
来源:https://stackoverflow.com/questions/25411504/reading-rss-feed-and-displaying-it-in-django-template-feedparser