Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 05-12-2008, 06:42 AM   #1
harrynewman
Member
harrynewman began at the beginning.
 
Posts: 24
Karma: 28
Join Date: Mar 2008
Device: Sony Reader
Calibre custom news feed and python help.

Hallo!

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:

Code:
http://www.guardian.co.uk/politics/2008/may/12/alistairdarling.taxandspending?gusrc=rss&feed=politics
The print version of the url looks like this:
Code:
http://www.guardian.co.uk/politics/2008/may/12/alistairdarling.taxandspending/print
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:

Code:
def print_version(self, url): 
        article = urlparse.urlparse(url).path.rpartition('/')[-1]
        return 'http://www.guardian.co.uk/'+article
Any help is MUCH appreciated.
harrynewman is offline   Reply With Quote
Old 05-12-2008, 08:50 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 24,817
Karma: 4369673
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Code:
def print_version(url):
    return url.partition('?')[0] + '/print'
kovidgoyal is offline   Reply With Quote
 
Enthusiast
Old 05-23-2008, 02:26 PM   #3
Ben_B
Junior Member
Ben_B began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Apr 2008
Location: British Columbia, Canada
Device: Sony PRS-505
thanks

... thanks

Last edited by Ben_B; 05-23-2008 at 02:30 PM. Reason: wrong thread
Ben_B is offline   Reply With Quote
Old 05-30-2008, 06:32 AM   #4
harrynewman
Member
harrynewman began at the beginning.
 
Posts: 24
Karma: 28
Join Date: Mar 2008
Device: Sony Reader
Aye, thanks from me too. I forgot to return and say that it worked.

harrynewman is offline   Reply With Quote
Old 10-08-2009, 09:26 AM   #5
parabolee
Junior Member
parabolee began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Oct 2009
Device: Kindle 2
I'm new to this too and was looking for how to subscribe to the Guardian. Any chance you could share that code and point me in the right direction on how to set it up?

THANKS!
parabolee is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
News Feed Covers DenverReader Calibre 4 02-06-2010 12:00 AM
calibre 0.6.20 won't complete NY Times news feed Zapped Calibre 9 11-13-2009 10:41 AM
Help Creating custom RSS feed need only the image Malakai Calibre 0 07-31-2009 04:28 PM
Missing Text in Custom feed kitzj0 Calibre 3 02-16-2009 10:29 PM
Share your LibPRS Python RSS Feeds and where to obtain more feed links! GatorDeb Calibre 15 03-05-2008 06:30 AM


All times are GMT -4. The time now is 10:04 AM.


MobileRead.com is a privately owned, operated and funded community.