4

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?

mircealungu
  • 6,831
  • 7
  • 34
  • 44

1 Answers1

1

After a bit more investigation I found out this in the documentation:

Note: As of version 5.1.1, if feed.updated key doesn’t exist but feed.published does, the value of feed.published will be returned.

Thus, it seems that one could rely only on feed.updated, respectively feed.updated_parsed to do the work.

mircealungu
  • 6,831
  • 7
  • 34
  • 44