我想要做的是从我的wordpress博客中提取Feed数据的标题和网址,并将其显示为我的Django模板中的链接。
我找到了this example
但它在Django中并没有用。 (我是n00b)。所以我想知道是否有人对如何获取费用并将其放入Django应用程序有任何建议?
<a href="link-to-feed">Title of blog post</a>
提前感谢您的帮助。
答案 0 :(得分:3)
基本上你需要在Django View中解析你的wordpress feed,然后将渲染的数据发送到你的模板。
Good Resource 还有feedparser规范:http://pythonhosted.org/feedparser/
在Django视图中用Python解析XML进行一些研究
1. Hit the Wordpress Feed URL in view.py
2. Parse the resulting XML nodes (or feedparser I think)
3. Extract needed data
4. Send data to your django template from the view
答案 1 :(得分:0)
我知道这个帖子已经老了,但我发现这也很有帮助: http://geekscrap.com/2010/02/integrate-wordpress-and-django/
我正在使用选项2,xmlrpc。这是示例的github页面
https://github.com/maxcutler/python-wordpress-xmlrpc/blob/master/docs/examples/posts.rst
从另一个答案开始,这就从rss feed中拉出来了。我不知道这个解决方案与其他解决方案相比有多高效,抱歉。