阅读RSS feed并在Django模板中显示它| feedparser [英] Reading RSS feed and displaying it in Django Template | feedparser

查看:96
本文介绍了阅读RSS feed并在Django模板中显示它| feedparser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅此博客: http://johnsmallman.wordpress.com/author/johnsmallman/feed /

我想为我的应用程序获取RSS feed。上面的博客是wordpress博客。

I want to fetch the RSS feed for my application. The above blog is a wordpress blog.

我正在使用 feedparser

import feedparser
feeds = feedparser.parse('http://johnsmallman.wordpress.com/author/johnsmallman/feed/')

现在 feeds ['feed'] ['title'] 输出 u Johnsmallman的博客\xbb John Smallman

我的问题是我在应用程序中的显示方式如何。可以说这个博客包含100篇文章。所以我想循环访问并获取所有数据。

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?

我经常在Google上搜索但遇到了困难。

I have ofcouse googled but had hard time.

我基本上是希望将其呈现给Django模板。

I am basically looking to render it to Django Template. So would really be looking something towards it.

需要指导人员:)

推荐答案

如果将 Feed 添加到模板上下文中,则应该能够在模板中对其进行循环:

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>

这篇关于阅读RSS feed并在Django模板中显示它| feedparser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆