see whatever…

jump to menu

December 17, 2005

Python, RSS, Powerpoint

Filed under: Python,RSS/Atom — see @ 8:53 pm

I read the very interesting post on converting RSS to PPT. Davy uses RSS.py with which I had problems as it uses the signal library which seems a bit platform dependent and therefore lacking a few things in Windows. The script does work without signal but I choose to use rssparser.py by Mark Pilgrim which I knew of but never really used before. I read the Python and RSS intro by Uche Ogbuji and Mike Olson. This article is actually from 2002 and rssparser has been changed a bit. It was easy to figure out the changes to do and so I run the RSS to PPT conversion with the following code:


import rssparser
import win32com.client

RSSFeed = "http://cthedot.de/rss.rdf"

feed = rssparser.parse(RSSFeed)
##feedkeys = ['feed',
##    'status',   # HTTP status
##    'version',  # RSS version
##    'encoding', # RSS encoding
##    'url',      # RSS URL
##    'headers',  # HTTP headers
##    'etag',     # ?
##    'entries',  # RSS items
##    'bozo']     # encoding bozo

PowerPoint = win32com.client.Dispatch(r'PowerPoint.Application')
Presentation = PowerPoint.presentations.add()

for item in feed['entries']:
    ppSlide1 = Presentation.Slides.Add(1,2)
    ppSlide1.Shapes(1).TextFrame.TextRange.Text = item.get('title', "(none)")
    ppSlide1.Shapes(2).TextFrame.TextRange.Text = item.get('description', "(none)")

Presentation.SaveAS("d:\\dev\\py\\test.ppt")

Really nice. I don’t really know if it may be useful for professional projects as of course it needs Windows with Powerpoint installed which is a problem on most webservers which came into my mind for a possible option where to use it…

I guess I should look a bit more into the win32all package (or maybe better IronPython?).

Powered by WordPress