简体   繁体   中英

How to check if Rss has been updated when there's no Etag support

I've tried this code but it doesn't seem to work:

import feedparser 
import time


c = feedparser.parse('http://www.tsa-algerie.com/feed/')
constID = c['entries'][0].id
print c['entries'][0]['title']
while True:
    time.sleep(300) 
    if constID != c['entries'][0].id:
        print c['entries'][0].title
        constID = c['entries'][0].id

RSS feeds are "dumb" and by default, they won't propagate updates , which means that, if you need to know if a feed has been updated, you'll have to fetch it yourself, and compare 2 successive versions.

There are protocols, on top of RSS which may help, including PubSubHubbub which lets you subscribe to an existing hub to be notified (via Webhooks) when a feed has been updated. Superfeedr provides a default hub which works with any feed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM