Getting Rss feed, periodically, using Python

878 Views Asked by At

I am trying to build an algorithms that get rss items. I could do that using feedparser. However, I couldn't get the update items.

When I execute the code

data = feedparser.parse(URL)

I want to do that automatically, without running the script every

for x in data
// Check if the entries is new 
   if x.link not in data["links"]: 
   // storing the data. 

I though of using a Timer so I keep the script running on server, and running it every one hour.

How can I do solve this problem ?

1

There are 1 best solutions below

0
On BEST ANSWER

If I understand the question, you're looking to set up a cron job. You DON'T want your program to sit running on the server all the time, with a timer running inside the program. Instead, the cron daemon which is running on the server as a service has a timer, and you schedule when you want your program to run, and where it's found. On Unix, Linux, and similar, you're looking for cron. On Mac, you can use cron, but apparently the preferred similar built-in tool is launchd. On Windows, you want Windows Scheduler. All of these do essentially the same thing. The programs to run and the scheduling info is kept in a table file, but there are gui tools for each of the above to help you so you don't have to mess with crontab or similar syntax. You can google any of these, depending on what OS your server is running.