I'm using feedparser and it seems that for a vast majority of feed items have a published_parsed field. However, some others only have an updated_parsed field.
How do I know when to use one or the other? Am I safe if I use either one or the other, something like this?
def get_publishing_date(item):
try:
return item.published_parsed
except:
return item.updated_parsed
Does feedparser not offer this abstraction itself?
After a bit more investigation I found out this in the documentation:
Note: As of version 5.1.1, if
feed.updatedkey doesn’t exist butfeed.publisheddoes, the value offeed.publishedwill be returned.
Thus, it seems that one could rely only on feed.updated, respectively feed.updated_parsed to do the work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With