问题
Using feedparser or some other Python library to download and parse RSS feeds; how can I reliably detect new
items and modified
items?
So far I have seen new items in feeds with publication dates earlier than the latest item. Also I have seen feed readers displaying the same item published with slightly different content as seperate items. I am not implementing a feed reader application, I just want a sane strategy for archiving feed data.
回答1:
It depends on how much you trust the feed source. feedparser provides an .id attribute for feed items -- this attribute should be unique for both RSS and ATOM sources. For an example, see eg feedparser's ATOM docs. Though .id will cover most cases, it's conceivable that a source might publish multiple items with the same id. In that case, you don't have much choice but to hash the item's content.
来源:https://stackoverflow.com/questions/700607/how-to-detect-changed-and-new-items-in-an-rss-feed