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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. www.inquirer.net
  7. '''
  8.  
  9. from calibre.web.feeds.recipes import BasicNewsRecipe
  10. from calibre.ebooks.BeautifulSoup import Tag
  11.  
  12. class InquirerNet(BasicNewsRecipe):
  13.     title                  = 'Inquirer.net'
  14.     __author__             = 'Darko Miletic'
  15.     description            = 'News from Philipines'
  16.     oldest_article         = 2
  17.     max_articles_per_feed  = 100
  18.     no_stylesheets         = True
  19.     use_embedded_content   = False
  20.     encoding               = 'cp1252'
  21.     publisher              = 'inquirer.net'
  22.     category               = 'news, politics, philipines'
  23.     lang                   = 'en'
  24.     language = 'en'
  25.  
  26.     extra_css              = ' .fontheadline{font-size: x-large} .fontsubheadline{font-size: large} .fontkick{font-size: medium}'
  27.  
  28.     html2lrf_options = [
  29.                           '--comment', description
  30.                         , '--category', category
  31.                         , '--publisher', publisher
  32.                         , '--ignore-tables'
  33.                         ]
  34.  
  35.     html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\nlinearize_tables=True'
  36.  
  37.     remove_tags = [dict(name=['object','link','script','iframe','form'])]
  38.  
  39.     feeds = [
  40.                (u'Breaking news', u'http://services.inquirer.net/rss/breakingnews.xml'             )
  41.               ,(u'Top stories'  , u'http://services.inquirer.net/rss/topstories.xml'               )
  42.               ,(u'Sports'       , u'http://services.inquirer.net/rss/brk_breakingnews.xml'         )
  43.               ,(u'InfoTech'     , u'http://services.inquirer.net/rss/infotech_tech.xml'            )
  44.               ,(u'InfoTech'     , u'http://services.inquirer.net/rss/infotech_tech.xml'            )
  45.               ,(u'Business'     , u'http://services.inquirer.net/rss/inq7money_breaking_news.xml'  )
  46.               ,(u'Editorial'    , u'http://services.inquirer.net/rss/opinion_editorial.xml'        )
  47.               ,(u'Global Nation', u'http://services.inquirer.net/rss/globalnation_breakingnews.xml')
  48.             ]
  49.  
  50.     def preprocess_html(self, soup):
  51.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  52.         mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
  53.         soup.head.insert(0,mlang)
  54.         soup.head.insert(1,mcharset)
  55.         for item in soup.findAll(style=True):
  56.             del item['style']
  57.         return soup
  58.  
  59.     def print_version(self, url):
  60.         rest, sep, art = url.rpartition('/view/')
  61.         art_id, sp, rrest = art.partition('/')
  62.         return 'http://services.inquirer.net/print/print.php?article_id=' + art_id
  63.