Example 5: Read RSS feeds

You can read the content of an RSS feed just by typing the url:

from NLUlite import ServerProxy, Wisdom

server   = ServerProxy()
wisdom   = Wisdom(server)
wisdom.add_feed('http://en.wikinews.org/w/index.php?title=Special:NewPages&feed=rss')
answer  = wisdom.ask('what happens where')

print answer.comment()
for item in answer.elements():
    print item.comment()

As for the webpage example, it is convenient to split the code into a fetching part

from NLUlite import ServerProxy, Wisdom

server   = ServerProxy()
wisdom   = Wisdom(server)
wisdom.add_feed('http://en.wikinews.org/w/index.php?title=Special:NewPages&feed=rss')
wisdom.save('fetched.wisdom')

and a part that loads the fetched wisdom and ask the question:

from NLUlite import ServerProxy, Wisdom

server   = ServerProxy()
wisdom   = Wisdom(server)
wisdom.load('fetched.wisdom')
answer  = wisdom.ask('what happens where')

print answer.comment()
for item in answer.elements():
    print item.comment()