tags:

views:

83

answers:

2

Hi,

I have list of 200 rss feeds, which I have to downloading. It's continuous process - I have to download every post, nothing can be missing, but also no duplicates. So best practice should be remember last update of feed and control it for change in x-hour interval? And how to handle if downloader will be restarted? So downloader should remember, what were downloaded and dont download it again...

It's somewhere implemented yet? Or any tips for article? Thanks

+2  A: 

You can use feedparser to parse the feeds and store in a database the maximal published time per feed.

For a simple database you can use shelve.

lazy1
The `sqlite3` module is nicer than `shelve` for a database. `sqlite3` implements the Python DB API which means code using it is easily ported to other DBs, doesn't have the security problems `shelve` has, and its databases can be used by programs in different languages. Even if these needs are not immediately advantageous, they do suggest to me that it is much more worth learning for someone who knows neither.
Mike Graham
+3  A: 

Typically this is what you'd want to do:

  • Fetch the feeds periodically and parse them using the universal feedparser and store the entries somewhere.
  • Use ETags and IfModified headers when fetching feeds to avoid parsing feeds that have not changed since your last fetch. you'll have to maintain Etags and Ifmodified values recieved during last fetch of the feed.
  • To avoid duplication, each entry should be stored with its unique guid, then check whether an entry with the same guid is already stored or not. (fall back through entry_link, hash of title+feed url to uniquely identify the entry, in case the feed entries have no guid)
z33m
Working hard on solution.
Vojtech R.
I have class for every feed, which checks feed and remember last if-modified (and also select fresh articles). Info about feeds are also stored in db. The method updating row in db about feed could be implemented in feed class? So about 200 feed class instances have to remember connection to db and update themes row in table OR it could be implemented in special class? I have low experience in object-oriented design...
Vojtech R.
im sorry i didnt quite understand.. why do you need to maintain 200 db connections?.. if its the schema, then a simple model would be to have a table for feeds, and a table for feed entries. In each feed table row you can store info like the feed url, title, etags, headers etc.. then in feed entry table you can have the actual info like the article title, description etc.. to link entries to feeds, you can have a foreign key in entry table which maps to it feed table row..
z33m
Program done. Thanks a lot.
Vojtech R.