Reading RSS feed and displaying it in Django Template | feedparser

我们两清 提交于 2019-12-06 10:21:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!