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

  1. from calibre.web.feeds.news import BasicNewsRecipe
  2.  
  3. class ElFaroDeVigo(BasicNewsRecipe):
  4.     title          = u'El Faro de Vigo'
  5.     oldest_article = 1
  6.     max_articles_per_feed = 100
  7.     __author__  = 'Jefferson Frantz'
  8.     description = 'Noticias de Vigo'
  9.     timefmt = ' [%d %b, %Y]'
  10.     language = 'es'
  11.     encoding               = 'cp1252'
  12.     no_stylesheets = True
  13.     remove_javascript = True
  14.  
  15.     feeds          = [
  16. ##                        (u'Vigo', u'http://www.farodevigo.es/elementosInt/rss/1'),
  17. ##                        (u'Gran Vigo', u'http://www.farodevigo.es/elementosInt/rss/2'),
  18.                         (u'Galicia', u'http://www.farodevigo.es/elementosInt/rss/4'),
  19.                         (u'Espa├▒a', u'http://www.farodevigo.es/elementosInt/rss/6'),
  20.                         (u'Mundo', u'http://www.farodevigo.es/elementosInt/rss/7'),
  21. ##                        (u'Opini├│n', u'http://www.farodevigo.es/elementosInt/rss/5'),
  22.                         (u'Econom├¡a', u'http://www.farodevigo.es/elementosInt/rss/10'),
  23.                         (u'Sociedad y Cultura', u'http://www.farodevigo.es/elementosInt/rss/8'),
  24.                         (u'Sucesos', u'http://www.farodevigo.es/elementosInt/rss/9'),
  25.                         (u'Deportes', u'http://www.farodevigo.es/elementosInt/rss/11'),
  26.                         (u'Agenda', u'http://www.farodevigo.es/elementosInt/rss/21'),
  27.                         (u'Gente', u'http://www.farodevigo.es/elementosInt/rss/24'),
  28.                         (u'Televisi├│n', u'http://www.farodevigo.es/elementosInt/rss/25'),
  29.                         (u'Ciencia y Tecnolog├¡a', u'http://www.farodevigo.es/elementosInt/rss/26')]
  30.  
  31.     extra_css              = '''.noticia_texto{ font-family: sans-serif; font-size: medium; text-align: justify }
  32.                                 h1{font-family: serif; font-size: x-large; font-weight: bold; color: #000000; text-align: center}
  33.                                 h2{font-family: serif; font-size: medium; font-weight: bold; color: #000000; text-align: left}
  34.                                 .enlacenegrita10{font-family: serif; font-size: small; font-weight: bold; color: #000000; text-align: left}
  35.                                 .noticia_titular{font-family: serif; font-size: x-large; font-weight: bold; color: #000000; text-align: center}'''
  36.  
  37.  
  38.     def preprocess_html(self, soup):
  39.             for item in soup.findAll(style=True):
  40.                del item['style']
  41.  
  42.             url = 'http://estaticos00.farodevigo.es//elementosWeb/mediaweb/images/compartir/barrapunto.gif'
  43.             fitem = soup.find('img',src=url)
  44.             if fitem:
  45.                par = fitem.parent
  46.                par.extract()
  47.             url = 'http://estaticos01.farodevigo.es//elementosWeb/mediaweb/images/compartir/barrapunto.gif'
  48.             fitem = soup.find('img',src=url)
  49.             if fitem:
  50.                par = fitem.parent
  51.                par.extract()
  52.             url = 'http://estaticos02.farodevigo.es//elementosWeb/mediaweb/images/compartir/barrapunto.gif'
  53.             fitem = soup.find('img',src=url)
  54.             if fitem:
  55.                par = fitem.parent
  56.                par.extract()
  57.  
  58.             return self.adeify_images(soup)
  59.  
  60.     def postprocess_html(self, soup, first_fetch):
  61.         divs = soup.findAll(True, {'class':'enlacenegrita10'})
  62.         for div in divs:
  63.             div['align'] = 'left'
  64.  
  65.         return soup
  66.  
  67.  
  68.     keep_only_tags = [dict(name='div', attrs={'class':['noticias']})]
  69.  
  70.     remove_tags        = [
  71.                              dict(name=['object','link','script','ul','iframe','ol'])
  72.                             ,dict(name='div', attrs={'class':['noticiadd2', 'cintillo2', 'noticiadd', 'noticiadd2']})
  73.                             ,dict(name='div', attrs={'class':['imagen_derecha', 'noticiadd3', 'extraHTML']})
  74.  
  75.                          ]
  76.  
  77.  
  78.