我对 Python 中的 feedparser 库相当陌生。
试图从 RSS 提要中解析出完整的时间戳列表,我目前有:
import feedparser
from time import gmtime, strftime
d = feedparser.parse('http://www.bloomberg.com/feed/podcast/taking-stock.xml')
dPub = d.entries[0].published # out: u'Mon, 06 May 2013 08:19:36 -0400'
dPubPretty = strftime(dPub, gmtime())
print dPubPretty # out: Mon, 06 May 2013 08:19:36 -0400
# loop over d.entries[0:] - ???
# for all d.entries...
d.entries[1].published # out: u'Mon, 06 May 2013 08:16:15 -0400'
d.entries[2].published # out: u'Fri, 03 May 2013 09:01:50 -0400'
我想遍历所有 d.entries 并输出时间戳列表,因此应用 strftime() 后,输出将类似于:
# output goal:
Mon, 06 May 2013 08:19:36 -0400
Mon, 06 May 2013 08:16:15 -0400
Fri, 03 May 2013 09:01:50 -0400
...
参考这些文档:
feedparser - 内容规范化:http://pythonhosted.org/feedparser/content-normalization.html#advanced-normalization
time - 时间访问和转换:http ://docs.python.org/2/library/time.html#time.strftime