Blog-o! Notes from latte.ca

Tue, 21 Jan 2003
After seeing the EffNews plugin for Andrew Kuchling's journal, I was inspired to try creating one of my own, for Neil Gaiman's journal. I think it went pretty well, although I'ld like to spend a little more time on it, to do something prettier with the dates. Perhaps later.
urls = ["http://www.neilgaiman.com/journal/journal.asp"]

def simpleprovider(context, text):
    context.push("channel", title="Neil Gaiman", link=urls[0])
    header = '<font Class="bold"> Journal:<font>'
    signature = '<blockquote>'
    i = j = k = 0
    j = text.find(header, j)
    while 1:
        i = text.find(signature, j)
        if i < 0:
            break
        j = text.find(signature, i+len(signature))
        if j < 0:
            break

        description = text[i:j]
        context.push("item", link=urls[0], description=description)

if __name__ == "__main__":
    # test wrapper
    import urllib
    class context:
        def push(self, tag, **kw):
            print tag, kw
    simpleprovider(context(), urllib.urlopen(urls[0]).read())
[Posted at 12:08 by Blake Winton] link
blog comments powered by Disqus