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

  1. #!/usr/bin/env  python
  2. __license__   = 'GPL v3'
  3. __copyright__ = '2010, Brendan Sleight <bms.calibre at barwap.com>'
  4. '''
  5. impreso.milenio.com
  6. '''
  7. from calibre import strftime
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9.  
  10. import datetime
  11.  
  12. class Milenio(BasicNewsRecipe):
  13.     title                 = u'Milenio-diario'
  14.     __author__            = 'Bmsleight'
  15.     language              = 'es_MX'
  16.     description           = 'Milenio-diario'
  17.     oldest_article        = 10
  18.     max_articles_per_feed = 100
  19.     no_stylesheets        = False
  20.     index                 = 'http://impreso.milenio.com'
  21.  
  22.     keep_only_tags      = [
  23.                            dict(name='div', attrs={'class':'content'})
  24.                           ]
  25.  
  26.     def parse_index(self):
  27.         # "%m/%d/%Y"
  28.         # http://impreso.milenio.com/Nacional/2010/09/01/
  29.         totalfeeds = []
  30.         soup   = self.index_to_soup(self.index + "/Nacional/" + datetime.date.today().strftime("%Y/%m/%d"))
  31.         maincontent = soup.find('div',attrs={'class':'content'})
  32.         mfeed = []
  33.         if maincontent:
  34.             for itt in maincontent.findAll('a',href=True):
  35.                 if "/node/" in str(itt['href']):
  36.                     url   = self.index + itt['href']
  37.                     title = self.tag_to_string(itt)
  38.                     description = ''
  39.                     date  = strftime(self.timefmt)
  40.                     mfeed.append({
  41.                                   'title'      :title
  42.                                  ,'date'       :date
  43.                                  ,'url'        :url
  44.                                  ,'description':description
  45.                                 })
  46.         totalfeeds.append(('Articles', mfeed))
  47.         return totalfeeds
  48.