I have the following code which works well when I try to get the date from any RSS feed(Using Universal feed Parser):
for entry in RSS_FEED.entries:
FEE开发者_StackOverflow社区D_DATE=entry.updated_parsed
FEED_DATE_STRING = datetime.fromtimestamp(mktime(FEED_DATE))
FEED_DATE_STRING = str(FEED_DATE_STRING)
FEED_DATE_STRING = Datetime.ParseDate(FEED_DATE_STRING).strftime('%a %b %d, %Y')
But while parsing the following RSS format:
<item>
<title>Title</title>
<description>
Description
</description>
<lastBuildDate>Wed, 5 Oct 2011 03:11:00:00 +0700</lastBuildDate>
<pubDate>Wed, 5 Oct 2011 03:11:00:00 +0700</pubDate>
</item>
I am getting the error in Log file:
FEED_DATE_STRING = datetime.fromtimestamp(mktime(FEED_DATE)) TypeError: argument must be 9-item sequence, not None
Assuming that you're using the feedparser package to parse the rss: the reason for the error in the log file is that you are using a date format that feedparser does not understand. This means entry.updated_parsed
will get set to None
. The problem seems to be the fourth element in the time field. If the dates are changed to:
Wed, 5 Oct 2011 03:11:00 +0700
then feedparser handles them correctly.
精彩评论