Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between updated_parsed and published_parsed with feedparser in Python

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?

like image 407
mircealungu Avatar asked Nov 26 '25 11:11

mircealungu


1 Answers

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.

like image 62
mircealungu Avatar answered Nov 29 '25 00:11

mircealungu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!