Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do nothing if RSS feed hasn't changed

Tags:

python

I want to run a Python script every so many minutes. The script starts by fetching the newest article from a rss-feed (using feedparser). What I want, is when the newest article is the same as the last time it ran, the script just ends. How do I accomplish this?

like image 312
HankSmackHood Avatar asked Nov 18 '25 00:11

HankSmackHood


2 Answers

Since you mention feedparser in a python question, I'll assume you mean feedparser.org

If yes, then the easiest way to do this is make the server do most of the work for you and only request updates since the last change you fetched: See ETag and Last-Modified headers for RSS feeds

like image 69
typo.pl Avatar answered Nov 20 '25 15:11

typo.pl


You could store the state in a temporary file. E.g. write the title into a temporary file if there isn't a temporary file already, and next time read from the file and compare the read title with the new title.

like image 28
Enno Shioji Avatar answered Nov 20 '25 15:11

Enno Shioji



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!