- 论坛徽章:
- 0
|
[color="#8080ff"]#!/usr/bin/python
[color="#8080ff"]# -*- coding: utf8 -*-
[color="#ff40ff"]import datetime, PyRSS2Gen
rss = PyRSS2Gen.RSS2(
title = "[color="#ff6060"]Andrew's PyRSS2Gen feed",
link = "[color="#ff6060"]http://www.dalkescientific.com/Python/PyRSS2Gen.html",
description = "[color="#ff6060"]The latest news about PyRSS2Gen, a Python library for generating RSS2 feeds",
lastBuildDate = datetime.datetime.now(),
items = [
PyRSS2Gen.RSSItem(
title = "[color="#ff6060"]PyRSS2Gen-0.0 released",
link = "[color="#ff6060"]http://www.dalkescientific.com/news/030906-PyRSS2Gen.html",
description = "[color="#ff6060"]Dalke Scientific today announced PyRSS2Gen-0.0, a library for generating RSS feeds for Python. ",
guid = PyRSS2Gen.Guid("[color="#ff6060"]http://www.dalkescientific.com/news/030906-PyRSS2Gen.html"),
pubDate = datetime.datetime(2003, 9, 6, 21, 31)
),
PyRSS2Gen.RSSItem(
title = "[color="#ff6060"]Thoughts on RSS feeds for bioinformatics",
link = "[color="#ff6060"]http://www.dalkescientific.com/writings/diary/archive/2003/09/06/RSS.html",
description = "[color="#ff6060"]One of the reasons I wrote PyRSS2Gen was to experiment with RSS for data collection in bioinformatics. Last year I came across...",
guid = PyRSS2Gen.Guid("[color="#ff6060"]http://www.dalkescientific.com/writings/diary/archive/2003/09/06/RSS.html"
),
pubDate = datetime.datetime(2003, 9, 6, 21, 49)),
]
)
rss.write_xml(open("[color="#ff6060"]pyrss2gen.xml", "[color="#ff6060"]w"))
文件:PyRSS2Gen-1.0.0.tar.gz
大小:8KB
下载:
下载
[color="#8080ff"]#!/usr/bin/python
[color="#8080ff"]# -*- coding: utf8 -*-
[color="#ff40ff"]import feedparser
f = feedparser.parse(r'[color="#ff6060"]http://bbs2.chinaunix.net/rss.php?fid=31&auth=0')
[color="#ffff00"]print f['[color="#ff6060"]feed']['[color="#ff6060"]title']
[color="#ffff00"]for item [color="#ffff00"]in f.entries:
[color="#ffff00"]print item.title, item.author, item.link
文件:feedparser-4.1.zip 大小:252KB
下载:下载&
lt;/a>
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/21842/showart_2091018.html |
|