RSS feed parser

Florian Lindner Florian.Lindner at
Wed Apr 4 12:45:50 CEST 2007

irstas at wrote:

> On Apr 2, 10:20 pm, Florian Lindner <Florian.Lind... at> wrote:
>> Some of the question I have but found answered nowhere:
>> I have a feedparser object that was created from a string. How can I
>> trigger a update (from a new string) but the feedparser should treat the
>> new string like the same feed (thus setting feed.updated etc.).
> Hmm. Do you mean that the feed object should stay the same? Like the
> difference between "a = [1,2,3]; a = [1,2,3]+[4]" and "a = [1,2,3];
> a.append(4)"? I glanced at the parse function in the source code and
> it looks like it's not directly possible. You could modify it so that
> the "result" dictionary is optionally given as an argument, so when
> updating you'd do: feedparser.parse(string, oldFeed). You'd also have
> to clear the oldFeed object before update.
> But you might also be able to solve the problem by using an additional
> layer of indirection. Instead of passing around the "feed" object,
> you'd pass around a proxy object like this:
> class Empty: pass
> proxy = Empty()
> proxy.feed = feedparser.parse(string)
> storeProxyForLaterUse(proxy)
> proxy.feed = feedparser.parse(string2)
> useStoredProxy() #this would use the updated feed through the proxy
> Then just use proxy.feed.updated everywhere instead of directly
> feed.updated. A smarter proxy would automatically translate
> proxy.updated into proxy.feed.updated so usage would stay as simple as
> without the proxy. Doing this is quite easy in Python (search for
> __getattr__ examples).

I already use something like that (with __getattr__). The problem is that
with this way there is still a new feed object created everytime a new
string needs to be passed to.
But since I want to use use the updated_parsed etc. function it's not
possible that each time the feed is parsed a new object is created (the
update times will always be the time of the last parsing).

Any idea?



More information about the Python-list mailing list