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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2008-2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. www.fastcompany.com
  7. '''
  8.  
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10. from calibre.ebooks.BeautifulSoup import Tag
  11.  
  12. class FastCompany(BasicNewsRecipe):
  13.     title                  = 'Fast Company'
  14.     __author__             = 'Darko Miletic'
  15.     description            = 'Where ideas and people meet'
  16.     publisher              = 'fastcompany.com'
  17.     category               = 'news, technology, gadgets, games'
  18.     oldest_article         = 15
  19.     max_articles_per_feed  = 100
  20.     no_stylesheets         = True
  21.     use_embedded_content   = True
  22.     simultaneous_downloads = 1
  23.     encoding               = 'utf-8'
  24.     lang                   = 'en'
  25.     language = 'en'
  26.  
  27.  
  28.     html2lrf_options = [
  29.                           '--comment', description
  30.                         , '--category', category
  31.                         , '--publisher', publisher
  32.                         ]
  33.  
  34.     html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
  35.  
  36.     remove_tags         = [dict(name=['embed','object']), dict(name='div',attrs={'class':'feedflare'})]
  37.  
  38.     feeds          = [(u'All News', u'http://feeds.feedburner.com/fastcompany/headlines')]
  39.  
  40.     def get_article_url(self, article):
  41.         return article.get('guid',  None)
  42.  
  43.     def preprocess_html(self, soup):
  44.         soup.html['xml:lang'] = self.lang
  45.         soup.html['lang']     = self.lang
  46.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  47.         mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=UTF-8")])
  48.         soup.head.insert(0,mlang)
  49.         soup.head.insert(1,mcharset)
  50.         for item in soup.findAll('a'):
  51.             sp = item['href'].find('http://feedads.g.doubleclick.net/')
  52.             if sp != -1:
  53.                item.extract()
  54.         return self.adeify_images(soup)
  55.  
  56.