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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010, Luciano Furtado <lrfurtado at yahoo.com.br>'
  3. '''
  4. www.superesportes.com.br
  5. '''
  6.  
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8.  
  9. class SuperEsportesRecipe(BasicNewsRecipe):
  10.  
  11.     title       = u'www.superesportes.com.br'
  12.     description = u'Superesportes - NotΓêÜΓëácias do esporte no Brasil e no mundo'
  13.     __author__  = 'Luciano Furtado'
  14.     language = 'pt'
  15.     category              = 'esportes, Brasil'
  16.     no_stylesheets        = True
  17.     oldest_article = 7
  18.  
  19.     use_embedded_content=0
  20.     max_articles_per_feed = 10
  21.     cover_url = 'http://imgs.mg.superesportes.com.br/superesportes_logo.png'
  22.  
  23.     extra_css = 'div.info_noticias h1 { font-size: 100% }'
  24.  
  25.  
  26.  
  27.     remove_tags = [
  28.                        dict(name='div',attrs={'class':'topo'}),
  29.                        dict(name='div',attrs={'class':'rodape'}),
  30.                        dict(name='div',attrs={'class':'navegacao'}),
  31.                        dict(name='div',attrs={'class':'lateral2'}),
  32.                        dict(name='div',attrs={'class':'leia_mais'}),
  33.                        dict(name='div',attrs={'id':'comentar'}),
  34.                        dict(name='div',attrs={'id':'vrumelc_noticia'}),
  35.                        dict(name='div',attrs={'class':'compartilhe'}),
  36.                        dict(name='div',attrs={'class':'linha_noticias'}),
  37.                        dict(name='div',attrs={'class':'botoes_noticias'}),
  38.                        dict(name='div',attrs={'class':'barra_time bg_time'}),
  39.                  ]
  40.  
  41.  
  42.  
  43.     def parse_index(self):
  44.         feeds = []
  45.         sections = [
  46.                        (u'Atletico', 'http://www.df.superesportes.com.br/futebol/atletico-mg/capa_atletico_mg/index.shtml'),
  47.                        (u'Botafogo', 'http://www.df.superesportes.com.br/futebol/botafogo/capa_botafogo/index.shtml'),
  48.                        (u'Corinthinas', 'http://www.df.superesportes.com.br/futebol/corinthians/capa_corinthians/index.shtml'),
  49.                        (u'Cruzeiro', 'http://www.df.superesportes.com.br/futebol/cruzeiro/capa_cruzeiro/index.shtml'),
  50.                        (u'Flamengo', 'http://www.df.superesportes.com.br/futebol/flamengo/capa_flamengo/index.shtml'),
  51.                        (u'Fluminense', 'http://www.df.superesportes.com.br/futebol/fluminense/capa_fluminense/index.shtml'),
  52.                        (u'Palmeiras', 'http://www.df.superesportes.com.br/futebol/palmeiras/capa_palmeiras/index.shtml'),
  53.                        (u'Santos', 'http://www.df.superesportes.com.br/futebol/santos/capa_santos/index.shtml'),
  54.                        (u'SΓêÜ┬úo Paulo', 'http://www.df.superesportes.com.br/futebol/sao-paulo/capa_sao_paulo/index.shtml'),
  55.                        (u'Vasco', 'http://www.df.superesportes.com.br/futebol/vasco/capa_vasco/index.shtml'),
  56.                    ]
  57.  
  58.  
  59.         for section, url in sections:
  60.             current_articles = []
  61.  
  62.             soup = self.index_to_soup(url)
  63.             latestNews =  soup.find(name='ul',attrs={'class': 'lista_ultimas_noticias'})
  64.  
  65.             for li_tag in latestNews.findAll(name='li'):
  66.                  a_tag = li_tag.find('a', href= True)
  67.                  if a_tag is None:
  68.                     continue
  69.                  title = self.tag_to_string(a_tag)
  70.                  url = a_tag.get('href', False)
  71.                  self.log("\n\nFound title: " + title + "\nUrl: " + url + "\nSection: " + section)
  72.                  current_articles.append({'title': title, 'url': url, 'description': title, 'date':''})
  73.  
  74.             if current_articles:
  75.                feeds.append((section, current_articles))
  76.  
  77.  
  78.         return feeds
  79.  
  80.