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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. daily.tportal.hr
  5. '''
  6.  
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8.  
  9. class Pagina12(BasicNewsRecipe):
  10.     title                 = 'Daily tportal.h'
  11.     __author__            = 'Darko Miletic'
  12.     description           = 'News from Croatia'
  13.     publisher             = 'tportal.hr'
  14.     category              = 'news, politics, Croatia'
  15.     oldest_article        = 2
  16.     max_articles_per_feed = 200
  17.     no_stylesheets        = True
  18.     encoding              = 'utf-8'
  19.     use_embedded_content  = False
  20.     language              = 'en_HR'
  21.     remove_empty_feeds    = True
  22.     publication_type      = 'newsportal'
  23.     extra_css             = """
  24.                                body{font-family: Verdana,sans-serif }
  25.                                img{margin-bottom: 0.4em; display:block}
  26.                                h1,h2{color: #2D648A; font-family: Georgia,serif}
  27.                                .artAbstract{font-size: 1.2em; font-family: Georgia,serif}
  28.                             """
  29.  
  30.     conversion_options = {
  31.                           'comment'   : description
  32.                         , 'tags'      : category
  33.                         , 'publisher' : publisher
  34.                         , 'language'  : language
  35.                         }
  36.  
  37.     remove_tags = [
  38.                      dict(name=['meta','link','embed','object','iframe','base'])
  39.                     ,dict(name='div', attrs={'class':'artInfo'})
  40.                   ]
  41.     remove_attributes=['lang']
  42.  
  43.     keep_only_tags=dict(attrs={'class':'articleDetails'})
  44.  
  45.     feeds = [(u'News', u'http://daily.tportal.hr/rss/dailynaslovnicarss.xml')]
  46.  
  47.     def preprocess_html(self, soup):
  48.         for item in soup.findAll(style=True):
  49.             del item['style']
  50.         for item in soup.findAll('a'):
  51.             limg = item.find('img')
  52.             if item.string is not None:
  53.                str = item.string
  54.                item.replaceWith(str)
  55.             else:
  56.                if limg:
  57.                   item.name = 'div'
  58.                   item.attrs = []
  59.                else:
  60.                    str = self.tag_to_string(item)
  61.                    item.replaceWith(str)
  62.         for item in soup.findAll('img'):
  63.             if not item.has_key('alt'):
  64.                item['alt'] = 'image'
  65.         return soup
  66.  
  67.