View Single Post
Old 02-07-2009, 07:11 PM   #184
tbaac
Member
tbaac began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Feb 2009
Device: Sony PRS505
Okay, I'm not sure what was going wrong. I tried it from the command line, found that sometimes it seemed that it helped if I closed Calibre and reopened it. It works really well now, thank you.

I changed some feeds and ended up with this:

Code:
#!/usr/bin/env  python

__license__   = 'GPL v3'
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
'''
newstatesman.com
'''

class NewStatesman(BasicNewsRecipe):
    title                 = 'New Statesman'
    __author__            = 'Darko Miletic'
    description           = "Britain's award-winning current affairs magazine"
    publisher             = 'New Statesman'
    category              = 'news, UK, World'
    oldest_article        = 7
    max_articles_per_feed = 100
    no_stylesheets        = True
    use_embedded_content  = False
    encoding              = 'cp1252'
    remove_javascript     = True
    cover_url             = 'http://media.starbulletin.com/designimages/spacer.gif'

    html2lrf_options = [
                          '--comment'       , description
                        , '--base-font-size', '10'
                        , '--category'      , category
                        , '--publisher'     , publisher
                        ]
    
    html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
    
    keep_only_tags = [dict(name='div', attrs={'class':'content-main'})]

    remove_tags = [
                    dict(name=['object','link','form','ul'])
                   ,dict(name='ul', attrs={'class':'post-article'})
                   ,dict(name='div' , attrs={'class':['tag-nav-container','article-base']})
                   ,dict(name='div' , attrs={'id':['reader-comments']})                    
                  ]
                        
    feeds = [
              (u'Politics', u'http://www.newstatesman.com/feeds/topics/politics.rss'), (u'Arts & Culture', u'http://www.newstatesman.com/feeds/topics/arts-and-culture.rss'), (u'Books', u'http://www.newstatesman.com/feeds/topics/books.rss'), (u'Life & Society', u'http://www.newstatesman.com/feeds/topics/life-and-society.rss'), (u'World Affairs', u'http://www.newstatesman.com/feeds/topics/world-affairs.rss'), (u'Columns - Martin Bright', u'http://www.newstatesman.com/feeds/writers/martin_bright.rss'), (u'Columns - Kira Cochrane', u'http://www.newstatesman.com/feeds/writers/kira_cochrane.rss'), (u'Columns - Hunter Davies', u'http://www.newstatesman.com/feeds/topics/world-affairs.rss'), (u'Columns - Noreena Hertz', u'http://www.newstatesman.com/feeds/writers/noreena_hertz.rss'), (u'Columns - Lindsey Hilsum', u'http://www.newstatesman.com/feeds/writers/lindsey_hilsum.rss'), (u'Columns - Darcus Howe', u'http://www.newstatesman.com/feeds/writers/darcus_howe.rss'), (u'Columns - Emma John', u'http://www.newstatesman.com/feeds/writers/emma_john.rss'), (u'Columns - Sadakat Kadri', u'http://www.newstatesman.com/feeds/writers/sadakat_kadri.rss'), (u'Columns - Mark Lynas', u'http://www.newstatesman.com/feeds/writers/mark_lynas.rss'), (u'Columns - Kevin Maguire', u'http://www.newstatesman.com/feeds/writers/kevin_maguire.rss'), (u'Columns - Rageh Omaar', u'http://www.newstatesman.com/feeds/writers/rageh_omaar.rss'), (u'Columns - John Pilger', u'http://www.newstatesman.com/feeds/writers/john_pilger.rss'), (u'Columns - Ziauddin Sardar', u'http://www.newstatesman.com/feeds/writers/ziauddin_sardar.rss'), (u'Columns - Clive Stafford-Smith', u'http://www.newstatesman.com/feeds/writers/clive_stafford_smith.rss'), (u'Columns - Michela Wrong', u'http://www.newstatesman.com/feeds/writers/michela_wrong.rss')
            ]

    def preprocess_html(self, soup):
        for item in soup.findAll(style=True):
            del item['style']
        mtag = '\n<meta http-equiv="Content-Language" content="en"/>\n'
        soup.head.insert(0,mtag)
        return soup
tbaac is offline