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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. dw-world.de
  5. '''
  6.  
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8.  
  9. class DeutscheWelle_pt(BasicNewsRecipe):
  10.     title                 = 'Deutsche Welle'
  11.     __author__            = 'Darko Miletic'
  12.     description           = 'Noticias desde Alemania y mundo'
  13.     publisher             = 'Deutsche Welle'
  14.     category              = 'news, politics, Germany'
  15.     oldest_article        = 1
  16.     max_articles_per_feed = 100
  17.     use_embedded_content  = False
  18.     no_stylesheets        = True
  19.     language              = 'pt'
  20.     publication_type      = 'newsportal'
  21.     remove_empty_feeds    = True
  22.     masthead_url          = 'http://www.dw-world.de/skins/std/channel1/pics/dw_logo1024.gif'
  23.     extra_css             = """
  24.                                 body{font-family: Arial,sans-serif}
  25.                                 img{margin-top: 0.5em; margin-bottom: 0.2em; display: block}
  26.                                 .caption{font-size: x-small; display: block; margin-bottom: 0.4em}
  27.                             """
  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=['iframe','embed','object','form','base','meta','link'])
  39.                     ,dict(attrs={'class':'actionFooter'})
  40.                   ]
  41.     keep_only_tags=[dict(attrs={'class':'ArticleDetail detail'})]
  42.     remove_attributes = ['height','width','onclick','border','lang']
  43.  
  44.     feeds          = [(u'Noticias', u'http://rss.dw-world.de/rdf/rss-br-all')]
  45.  
  46.     def print_version(self, url):
  47.         artl = url.rpartition('/')[2]
  48.         return 'http://www.dw-world.de/popups/popup_printcontent/' + artl
  49.  
  50.     def preprocess_html(self, soup):
  51.         for item in soup.findAll('a'):
  52.             limg = item.find('img')
  53.             if item.string is not None:
  54.                str = item.string
  55.                item.replaceWith(str)
  56.             else:
  57.                if limg:
  58.                   item.name = 'div'
  59.                   del item['href']
  60.                   if item.has_key('target'):
  61.                      del item['target']
  62.                else:
  63.                    str = self.tag_to_string(item)
  64.                    item.replaceWith(str)
  65.         return soup
  66.  
  67.