home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Calibre / calibre-0.8.18.msi / file_280 / utne.recipe < prev    next >
Text File  |  2011-09-09  |  2KB  |  52 lines

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2008, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. utne.com
  7. '''
  8.  
  9. from calibre.ebooks.BeautifulSoup import BeautifulSoup
  10. from calibre.web.feeds.news import BasicNewsRecipe
  11.  
  12. class Utne(BasicNewsRecipe):
  13.     title                 = u'Utne reader'
  14.     __author__            = 'Darko Miletic'
  15.     description           = 'News'    
  16.     oldest_article        = 7
  17.     max_articles_per_feed = 100
  18.     no_stylesheets        = True
  19.     use_embedded_content  = False
  20.     language = 'en'
  21.  
  22.     
  23.     cover_url = 'http://www.utne.com/images/template/logo.gif'
  24.     
  25.     remove_tags = [
  26.                      dict(name='a' , attrs={'id':'ctl00_blankmaster_lnkBanner' })
  27.                     ,dict(name='object')
  28.                   ]
  29.  
  30.     feeds          = [
  31.                         (u'Politics'     , u'http://www.utne.com/rss/Politics.xml')
  32.                        ,(u'Environment'  , u'http://www.utne.com/rss/Environment.xml')
  33.                        ,(u'Media'        , u'http://www.utne.com/rss/Media.xml')
  34.                        ,(u'Great writing', u'http://www.utne.com/rss/Great-Writing.xml')
  35.                        ,(u'Science & Technology', u'http://www.utne.com/rss/Science-Technology.xml')
  36.                        ,(u'Arts', u'http://www.utne.com/rss/Arts.xml')
  37.                      ]
  38.         
  39.     def print_version(self, url):
  40.         raw = self.browser.open(url).read()
  41.         soup = BeautifulSoup(raw.decode('utf8', 'replace'))
  42.         print_link = soup.find('a', {'id':'ctl00_defaultmaster_Blog_tools1_lnkPrint'})
  43.         if print_link is None:
  44.             return url
  45.         return print_link['href']
  46.  
  47.     def preprocess_html(self, soup):
  48.         mtag = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'
  49.         soup.head.insert(0,mtag)
  50.         del(soup.body['onload'])
  51.         return soup
  52.