libo26 / feedparser

Automatically exported from code.google.com/p/feedparser
Other
0 stars 0 forks source link

Missing support for lastBuildDate element in rss feed parse #136

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If I try and parse a feed using <lastBuildDate> instead of <pubDate> as a
child of <channel> to show the last update time of the feed, the element
doesn't get interpreted as [I think] it should, and I don't get 'updated'
and 'updated_parsed' on the feed: 
>>> import feedparser
>>> p=feedparser.parse('rss_w_lastBuild.xml')
>>> p.feed['updated_parsed']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/home/lorenzo/justfornow/lib/python2.5/site-packages/feedparser-4.1-py2.5.egg/f
eedparser.py",
line 200, in __getitem__
    return UserDict.__getitem__(self, realkey)
KeyError: 'updated_parsed'
>>> p.feed['lastbuilddate']
u'Sat, 07 Sep 2002 00:00:01 GMT'

With the enclosed two-liner patch, I get what I think is a more sensible
behaviour:

>>> import feedparser
>>> p=feedparser.parse('rss_w_lastBuild.xml')
>>> p.feed['updated_parsed']
(2002, 9, 7, 0, 0, 1, 5, 250, 0)
>>> p.feed['lastbuilddate']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/home/lorenzo/virtpython/lib/python2.5/site-packages/feedparser-4.1-py2.5.egg/f
eedparser.py",
line 200, in __getitem__
    return UserDict.__getitem__(self, realkey)
KeyError: 'lastbuilddate'

Original issue reported on code.google.com by lmcatu...@gmail.com on 25 Sep 2008 at 11:01

Attachments:

GoogleCodeExporter commented 9 years ago
I added the two lines of the patch, but it still not work.why

Original comment by JAVIER.C...@gmail.com on 2 Feb 2010 at 6:47

GoogleCodeExporter commented 9 years ago
Sorry, Javier, would you mind posting a failed test case?

The two liner patch is meant to have the lastbuilddate element interpreted
just as a synonym of the updated element.

If at all possible, upload your feed, and add an interpreter transcript just
like the one I posted above.

If you miss the updated and updated_parsed on your feed, please try if you miss 
them on rss_w_lastBuild.xml , and do a 
>>> print feedparser.__file__

to make sure you are not using an older installed feedparser instead 
of the patched one.

Thank you very much.

Original comment by lmcatu...@gmail.com on 2 Feb 2010 at 7:29

GoogleCodeExporter commented 9 years ago
I've taken lorenzo's patch and updated it to apply cleanly to svn trunk.

Attached are the diff and two wellformed unit tests. Illformed unit tests to 
follow. All unit tests run under Python 2.4 through 2.7. Git branch at:
https://github.com/kurtmckee/feedparser/tree/issue136

Original comment by kurtmckee on 5 Dec 2010 at 5:34

Attachments:

GoogleCodeExporter commented 9 years ago
Illformed versions.

Original comment by kurtmckee on 5 Dec 2010 at 5:35

Attachments:

GoogleCodeExporter commented 9 years ago
Patch applied in revision 330

Original comment by adewale on 12 Dec 2010 at 11:17