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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. axxon.com.ar
  7. '''
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9. from calibre.ebooks.BeautifulSoup import Tag
  10.  
  11. class Axxon_news(BasicNewsRecipe):
  12.     title                 = 'Axxon noticias'
  13.     __author__            = 'Darko Miletic'
  14.     description           = 'Axxon, Ciencia Ficcion en Bits'
  15.     publisher             = 'Axxon'
  16.     category              = 'news, SF, Argentina, science, movies'
  17.     oldest_article        = 7
  18.     max_articles_per_feed = 100
  19.     no_stylesheets        = False
  20.     use_embedded_content  = False
  21.     language = 'es_AR'
  22.  
  23.     lang                  = 'es-AR'
  24.  
  25.     conversion_options = {
  26.                           'comment'          : description
  27.                         , 'tags'             : category
  28.                         , 'publisher'        : publisher
  29.                         , 'language'         : lang
  30.                         , 'pretty_print'     : True
  31.                         }
  32.  
  33.  
  34.     keep_only_tags     = [dict(name='div', attrs={'class':'post'})]
  35.  
  36.     remove_tags = [dict(name=['object','link','iframe','embed'])]
  37.  
  38.     feeds          = [(u'Noticias', u'http://axxon.com.ar/noticias/feed/')]
  39.  
  40.     remove_attributes = ['style','width','height','font','border','align']
  41.  
  42.  
  43.     def adeify_images2(cls, soup):
  44.         for item in soup.findAll('img'):
  45.             for attrib in ['height','width','border','align','style']:
  46.                 if item.has_key(attrib):
  47.                    del item[attrib]
  48.             oldParent = item.parent
  49.             if oldParent.name == 'a':
  50.                oldParent.name == 'p'
  51.             myIndex = oldParent.contents.index(item)
  52.             brtag  = Tag(soup,'br')
  53.             oldParent.insert(myIndex+1,brtag)
  54.         return soup
  55.  
  56.     def preprocess_html(self, soup):
  57.         soup.html['xml:lang'] = self.lang
  58.         soup.html['lang']     = self.lang
  59.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  60.         soup.html.insert(0,mlang)
  61.         return self.adeify_images2(soup)
  62.  
  63.