View Single Post
Old 07-30-2010, 08:49 AM   #2366
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by sark666 View Post
I'm trying to make my first recipe but I can't see why this isn't working:

Spoiler:
Code:
class AdvancedUserRecipe1280289069(BasicNewsRecipe):
    title          = u'Metro Daily'
    oldest_article = 7
    max_articles_per_feed = 100

    feeds          = [(u'metro local', u'http://www.metronews.ca/Toronto/local/rss')]

    def print_version(self, url):
        baseurl='http://www.metronews.ca/ArticlePrint/' 
        split1 = string.split(url,"/")
        xxx=split1 [6]
        split2= xxx[0:5]
        s =  baseurl + split2
        return s

It's from metronews, a Canadian daily news publication.

A url story would look like:

"http://www.metronews.ca/toronto/local/article/587467--finally-someone-at-the-acc-does-well"

But you can just have the 6 digit identifer. And the print equivalent would be:

"http://www.metronews.ca/ArticlePrint/587467?language=en"

But you only need the 6 digit identifer. At first I was adding the language bit, but when it wasn't working I removed it.

I tried it as str.split and string.split. Can't see where else it's wrong.
If you use string, you need to import it. You don't need it, however. Try:
split1 = url.split("/")
instead of
split1 = string.split(url,"/")

Also, check that your results are correct with a print, as in:
print 'split2 is: ', split2
right after you calc split2
Starson17 is offline