免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4145 | 回复: 0
打印 上一主题 下一主题

python rss generator and parser [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-11-10 17:20 |只看该作者 |倒序浏览

                [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
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP