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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2009-2010, Darko Miletic <darko.miletic at gmail.com>'
  3.  
  4. '''
  5. english.aljazeera.net
  6. '''
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8.  
  9. class AlJazeera(BasicNewsRecipe):
  10.     title                  = 'Al Jazeera in English'
  11.     __author__             = 'Darko Miletic'
  12.     description            = 'News from Middle East'
  13.     language               = 'en'
  14.     publisher              = 'Al Jazeera'
  15.     category               = 'news, politics, middle east'
  16.     delay                  = 1
  17.     oldest_article         = 2
  18.     max_articles_per_feed  = 100
  19.     no_stylesheets         = True
  20.     encoding               = 'iso-8859-1'
  21.     use_embedded_content   = False
  22.     extra_css              = """
  23.                                 body{font-family: Arial,sans-serif}
  24.                                 #ctl00_cphBody_dvSummary{font-weight: bold}
  25.                                 #dvArticleDate{font-size: small; color: #999999}
  26.                              """
  27.     conversion_options = {
  28.                           'comment'   : description
  29.                         , 'tags'      : category
  30.                         , 'publisher' : publisher
  31.                         , 'language'  : language
  32.                         }
  33.  
  34.     keep_only_tags = [
  35.                          dict(attrs={'id':['DetailedTitle','ctl00_cphBody_dvSummary','dvArticleDate']})
  36.                         ,dict(name='td',attrs={'class':'DetailedSummary'})
  37.                      ]
  38.  
  39.     remove_tags = [
  40.                      dict(name=['object','link','table','meta','base','iframe','embed'])
  41.                     ,dict(name='td', attrs={'class':['MostActiveDescHeader','MostActiveDescBody']})
  42.                   ]
  43.  
  44.     feeds = [(u'AL JAZEERA ENGLISH (AJE)', u'http://english.aljazeera.net/Services/Rss/?PostingId=2007731105943979989' )]
  45.  
  46.     def get_article_url(self, article):
  47.         artlurl =  article.get('link',  None)
  48.         return artlurl.replace('http://english.aljazeera.net//','http://english.aljazeera.net/')
  49.  
  50.     def preprocess_html(self, soup):
  51.         for item in soup.findAll(style=True):
  52.             del item['style']
  53.         for item in soup.findAll(face=True):
  54.             del item['face']
  55.         td = soup.find('td',attrs={'class':'DetailedSummary'})
  56.         if td:
  57.            td.name = 'div'
  58.         spn = soup.find('span',attrs={'id':'DetailedTitle'})
  59.         if spn:
  60.            spn.name='h1'
  61.         for itm in soup.findAll('span', attrs={'id':['dvArticleDate','ctl00_cphBody_lblDate']}):
  62.             itm.name = 'div'
  63.         for alink in soup.findAll('a'):
  64.             if alink.string is not None:
  65.                tstr = alink.string
  66.                alink.replaceWith(tstr)
  67.         return soup
  68.  
  69.