View Single Post
Old 09-11-2010, 01:49 PM   #2689
willswords
Junior Member
willswords began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Sep 2010
Device: Kindle 3
DeseretNews.com recipe help request

Hi there. I'm new to Calibre and was wondering if someone could help me with my recipe for the Deseret News (Salt Lake City, Utah, USA Newspaper, http://desnews.com ). I've cobbled something together from what I have seen in other recipes, but I can't get it to use the mobile url instead of the regular one. The stories come through, but with all the extra stuff I don't want. The mobile versions of the articles look pretty clean though, but I must be doing something wrong because it isn't using the mobile url for the stories.

Here is what I have so far:

Spoiler:
Code:
from calibre.web.feeds.news import BasicNewsRecipe

class AdvancedUserRecipe1284222826(BasicNewsRecipe):
    title          = u'Deseret News mobile'
    __author__ =  'WillsWords'
    description = 'Deseret News selected feeds'
    category = 'news, politics, USA, Utah'
    oldest_article = 7
    max_articles_per_feed = 100
    no_stylesheets = True
    remove_javascript = True
    masthead_url = "http://www.deseretnews.com/media/img/icons/dn-masthead-logo.gif"

    feeds          = [(u'Top News', u'http://www.deseretnews.com/home/index.rss'), (u'Utah', u'http://www.deseretnews.com/utah/index.rss'), (u'Movies', u'http://www.deseretnews.com/movies/index.rss'), (u'LDS Newsline', u'http://www.deseretnews.com/ldsnews/index.rss'), (u'Sports', u'http://www.deseretnews.com/sports/index.rss')]

def print_version(self, url):
        split1 = url.split("/")
        #url1 = split1[0]
        #url2 = split1[1]
        url3 = split1[2]
        url4 = split1[3]
        url5 = split1[4]
        url6 = split1[5]


        #example of link to convert
        #http://www.deseretnews.com/article/700064426/Elizabeth-Smarts-father-joins-bike-ride-to-lobby-for-laws-protecting-children-from-predators.html
        #http://www.deseretnews.com/mobile/article/700064426/Elizabeth-Smarts-father-joins-bike-ride-to-lobby-for-laws-protecting-children-from-predators.html


        print_url = 'http://' + url3 + '/mobile/' + url4 + '/' + url5 + '/' + url6

        return print_url

Last edited by willswords; 09-11-2010 at 07:19 PM.
willswords is offline