home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_3738 < prev    next >
Encoding:
Text File  |  2009-10-30  |  7.1 KB  |  126 lines

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. eluniversal.com.mx
  7. '''
  8.  
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10.  
  11. class ElUniversal(BasicNewsRecipe):
  12.     title                 = 'El Universal'
  13.     __author__            = 'Darko Miletic and Sujata Raman'
  14.     description           = 'News from Mexico'
  15.     oldest_article        = 1
  16.     max_articles_per_feed = 100
  17.     publisher             = 'El Universal'
  18.     category              = 'news, politics, Mexico'
  19.     no_stylesheets        = True
  20.     use_embedded_content  = False
  21.     encoding              = 'cp1252'
  22.     remove_javascript     = True
  23.     language = 'es'
  24.  
  25.     extra_css = '''
  26.                     body{font-family:Arial,Helvetica,sans-serif; font-size:x-small;}
  27.                     .geoGris30{font-family:Georgia,"Times New Roman",Times,serif; font-size:large; color:#003366; font-weight:bold;}
  28.                     .arnegro16{font-family:Georgia,"Times New Roman",Times,serif; font-weight:bold; font-size:small;}
  29.                     .tbazull2{font-family:"trebuchet ms",Arial,Helvetica,sans-serif; color:#336699; font-size:xx-small;}
  30.                     .tbgrisf11{font-family:"trebuchet ms",Arial,Helvetica,sans-serif; color: #666666; font-size:xx-small;}
  31.                     .verrojo13{font-family:"trebuchet ms",Arial,Helvetica,sans-serif; color: #CC0033; font-size:xx-small;}
  32.                     .trnegro13{font-family:"trebuchet ms",Arial,Helvetica,sans-serif; font-size:xx-small;}
  33.                     .txt-fotogaleria{font-family:"trebuchet ms",Arial,Helvetica,sans-serif; font-size:xx-small;}
  34.                 '''
  35.     keep_only_tags = [ dict(name='table', attrs={'width':"633"}),dict(name='table', attrs={'width':"629"}),]
  36.  
  37.     remove_tags  = [
  38.                     dict(name='table', attrs={'bgcolor':"#f5f5f5"}),
  39.                      dict(name='td', attrs={'bgcolor':"#f7f8f9"}),
  40.                     dict(name='td', attrs={'bgcolor':"#f5f5f5"}),
  41.                     dict(name='table', attrs={'width':"302"}),
  42.                     dict(name='table', attrs={'width':"214"}),
  43.                     dict(name='table', attrs={'width':"112"}),
  44.                     dict(name='table', attrs={'width':"980"}),
  45.                     dict(name='td', attrs={'height':"1"}),
  46.                     dict(name='td', attrs={'height':"4"}),
  47.                      dict(name='td', attrs={'height':"20"}),
  48.                      dict(name='td', attrs={'height':"10"}),
  49.                     dict(name='td', attrs={'class':["trrojo11","trbris11","trrojo12","arrojo12s","tbazul13"]}),
  50.                     dict(name='div', attrs={'id':["mapg","ver_off_todosloscom","todosloscom"]}),
  51.                     dict(name='span', attrs={'class':["trazul18b","trrojo11","trnaranja11","trbris11","georojo18b","geogris18"]}),
  52.                     dict(name='span', attrs={'class':["detalles-opinion"]}),
  53.                     dict(name='a', attrs={'class':["arnaranja12b","trbris11","arazul12rel","trrojo10"]}),
  54.                     dict(name='img', src = "/img/icono_imprimir.gif"),
  55.                     dict(name='img', src = "/img/icono_enviar_mail.gif"),
  56.                     dict(name='img', src = "/img/icono_fuente_g.gif"),
  57.                     dict(name='img', src = "/img/icono_fuente_m.gif"),
  58.                     dict(name='img', src = "/img/icono_fuente_c.gif"),
  59.                     dict(name='img', src = "/img/icono_compartir.gif"),
  60.                     dict(name='img', src = "/img/icono_enviar_coment.gif"),
  61.                      dict(name='img', src = "http://www.eluniversal.com.mx/n_img/bot-notasrel.gif"),
  62.                     dict(name='img', src = "http://www.eluniversal.com.mx/n_img/fr.gif"),
  63.                     dict(name='img', src = "/img/espiral2.gif"),
  64.                     dict(name='img', src = "http://www.eluniversal.com.mx/n_img/b"),
  65.                     dict(name='img', src = "/img/icono_enviar_coment.gifot-notasrel.gif"),
  66.                     dict(name='img', src = "/n_img/icono_tipo3.gif"),
  67.                     dict(name='img', src = "/n_img/icono_tipo2.gif"),
  68.                     dict(name='img', src = "/n_img/icono_print.gif"),
  69.                     dict(name='img', src = "/n_img/icono_mail2.gif"),
  70.                     dict(name='img', src = "/n_img/im-comentarios-2a.gif"),
  71.                     dict(name='img', src = "/n_img/im-comentarios-1a.gif"),
  72.                     dict(name='img', src = "/img/icono_coment.gif"),
  73.                      dict(name='img', src = "http://www.eluniversal.com.mx/n_img/bot-sitiosrel.gif"),
  74.                     dict(name='img', src = "/n_img/icono_tipomenos.gif"),
  75.                     dict(name='img', src = "/img/futbol/19.jpg"),
  76.                     dict(name='img', alt = "Facebook"),
  77.                     dict(name='img', alt = "Twitter"),
  78.                     dict(name='img', alt = "Google"),
  79.                     dict(name='img', alt = "LinkedIn"),
  80.                     dict(name='img', alt = "Viadeo"),
  81.                     dict(name='img', alt = "Digg"),
  82.                     dict(name='img', alt = "Delicious"),
  83.                     dict(name='img', alt = "Meneame"),
  84.                     dict(name='img', alt = "Yahoo"),
  85.                     dict(name='img', alt = "Technorati"),
  86.                     dict(name='a',text =["Compartir","Facebook","Twitter","Google","LinkedIn","Viadeo","Digg","Delicious","Meneame","Yahoo","Technorati"]),
  87.                     dict(name='select'),
  88.                     dict(name='a', attrs={'class':"tbgriscompartir"}),
  89.                     ]
  90.  
  91.     feeds = [
  92.               (u'Minuto por Minuto', u'http://www.eluniversal.com.mx/rss/universalmxm.xml' )
  93.              ,(u'Mundo'            , u'http://www.eluniversal.com.mx/rss/mundo.xml'        )
  94.              ,(u'Mexico'           , u'http://www.eluniversal.com.mx/rss/mexico.xml'       )
  95.              ,(u'Estados'          , u'http://www.eluniversal.com.mx/rss/estados.xml'      )
  96.              ,(u'Finanzas'         , u'http://www.eluniversal.com.mx/rss/finanzas.xml'     )
  97.              ,(u'Deportes'         , u'http://www.eluniversal.com.mx/rss/deportes.xml'     )
  98.              ,(u'Espectaculos'     , u'http://www.eluniversal.com.mx/rss/espectaculos.xml' )
  99.              ,(u'Cultura'          , u'http://www.eluniversal.com.mx/rss/cultura.xml'      )
  100.              ,(u'Ciencia'          , u'http://www.eluniversal.com.mx/rss/ciencia.xml'      )
  101.              ,(u'Computacion'      , u'http://www.eluniversal.com.mx/rss/computo.xml'      )
  102.              ,(u'Sociedad'         , u'http://www.eluniversal.com.mx/rss/sociedad.xml'     )
  103.             ]
  104.  
  105.    # def print_version(self, url):
  106.    #     return url.replace('/notas/','/notas/vi_')
  107.  
  108.     def preprocess_html(self, soup):
  109.        mtag = '<meta http-equiv="Content-Language" content="es-MX"/><meta http-equiv="Content-Type" content="text/html; charset=utf-8">'
  110.        soup.head.insert(0,mtag)
  111.        for tag in soup.findAll(name='td',attrs={'class': 'arazul50'}):
  112.                  tag.insert(0,"<h1>")
  113.                  tag.insert(2,"</h1>")
  114.  
  115.        return soup
  116.  
  117.     def postprocess_html(self, soup,first):
  118.  
  119.          for tag in soup.findAll(name=['table', 'span','i']):
  120.                 tag.name = 'div'
  121.          for item in soup.findAll(align = "right"):
  122.                 del item['align']
  123.  
  124.          return soup
  125.  
  126.