View Single Post
Old 05-12-2008, 06:42 AM   #1
harrynewman began at the beginning.
Posts: 24
Karma: 28
Join Date: Mar 2008
Device: Sony Reader
Calibre custom news feed and python help.


I've been building a custom news feed for the UK guardian, but I have hit a problem because my knowledge of python is none existent

Here's the rub:

The rss feed returns an article url in the format of:

The print version of the url looks like this:
So I need to replace that last bit of the url, starting the question mark (which changes from feed to feed, ie politics changes to culture) and replace it with /print.

From looking at the included feeds I think I need to be using urlparse, but can't figure out how to structure it.

My starting point is this from the WSJ recipie, but obviously it won't work in its current form:

def print_version(self, url): 
        article = urlparse.urlparse(url).path.rpartition('/')[-1]
        return ''+article
Any help is MUCH appreciated.
harrynewman is offline   Reply With Quote