Python: how to check RSS updates with feedparser and etags

I am trying to skip RSS feeds that have not been modified using feedparser and etags. Following the documentation recommendations: http://pythonhosted.org/feedparser/http-etag.html

import feedparser d = feedparser.parse('http://www.wired.com/wiredscience/feed/') d2 = feedparser.parse('http://www.wired.com/wiredscience/feed/', etag=d.etag) print d2.status 

It is output:

 200 

Should this script return 304? I understand that when the RSS feed is updated, the stage changes, and if they match, I should get 304.

Why am I not getting the expected result?

+8
python rss etag feedparser
source share
1 answer

Apparently, this server is configured to check the "If-Modified-Since" header. You must also pass the last modified time:

 >>> d = feedparser.parse('http://www.wired.com/wiredscience/feed/') >>> feedparser.parse('http://www.wired.com/wiredscience/feed/', etag=d.etag, modified=d.modified).status 304 >>> feedparser.parse('http://www.wired.com/wiredscience/feed/', etag=d.etag).status 200 
+16
source share

All Articles