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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. bighollywood.breitbart.com
  5. '''
  6.  
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8.  
  9. class BigHollywood(BasicNewsRecipe):
  10.     title                 = 'Big Hollywood'
  11.     __author__            = 'Darko Miletic'
  12.     description           = 'News and articles from the media world'
  13.     publisher             = 'Big Hollywood'
  14.     category              = 'news, media, art, literature, movies, politics, USA, Hollywood'
  15.     oldest_article        = 7
  16.     max_articles_per_feed = 200
  17.     no_stylesheets        = True
  18.     encoding              = 'utf8'
  19.     use_embedded_content  = False
  20.     language              = 'en'
  21.     remove_empty_feeds    = True
  22.     publication_type      = 'blog'
  23.     extra_css             = """
  24.                                body{font-family: Arial,sans-serif }
  25.                             """
  26.  
  27.     conversion_options = {
  28.                           'comment'   : description
  29.                         , 'tags'      : category
  30.                         , 'publisher' : publisher
  31.                         , 'language'  : language
  32.                         }
  33.  
  34.     keep_only_tags=[dict(attrs={'class':'postcontent'})]
  35.     remove_tags = [
  36.                      dict(name=['meta','link','link','iframe','embed','object'])
  37.                     ,dict(name='p', attrs={'class':['post_meta_links','postfooter']})
  38.                   ]
  39.     remove_attributes=['original','onclick']
  40.  
  41.     feeds = [(u'Articles', u'http://bighollywood.breitbart.com/feed/')]
  42.  
  43.     def preprocess_html(self, soup):
  44.         for item in soup.findAll(style=True):
  45.             del item['style']
  46.         for item in soup.findAll('a'):
  47.             limg = item.find('img')
  48.             if item.string is not None:
  49.                str = item.string
  50.                item.replaceWith(str)
  51.             else:
  52.                if limg:
  53.                   if limg['src'].endswith('BlogPrintButton.png'):
  54.                      limg.extract()
  55.                   item.name = 'div'
  56.                   item.attrs = []
  57.                else:
  58.                    str = self.tag_to_string(item)
  59.                    item.replaceWith(str)
  60.         for item in soup.findAll('img'):
  61.             if not item.has_key('alt'):
  62.                item['alt'] = 'image'
  63.         return soup
  64.