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?
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With