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

  1. from calibre.ptempfile import PersistentTemporaryFile
  2. from calibre.web.feeds.news import BasicNewsRecipe
  3.  
  4. class AdvancedUserRecipe1276486274(BasicNewsRecipe):
  5.     title          = u'Today Online - Singapore'
  6.     publisher             = 'MediaCorp Press Ltd - Singapore'
  7.     __author__ = 'rty'
  8.     category              = 'news, Singapore'
  9.     oldest_article = 7
  10.     max_articles_per_feed = 100
  11.     remove_javascript = True
  12.     use_embedded_content   = False
  13.     no_stylesheets = True
  14.     language = 'en_SG'
  15.     temp_files = []
  16.     articles_are_obfuscated = True
  17.     masthead_url = 'http://www.todayonline.com/App_Themes/Default/images/icons/TodayOnlineLogo.gif'
  18.     conversion_options = {'linearize_tables':True}
  19.     extra_css = '''
  20.                    .author{font-style: italic; font-size: small}
  21.                    .date{font-style: italic; font-size: small}
  22.                    .Headline{font-weight: bold; font-size: xx-large}
  23.                    .headerStrap{font-weight: bold; font-size: x-large; font-syle: italic}
  24.                    .bodyText{font-size: 4px;font-family: Times New Roman;}
  25.                 '''
  26.     keep_only_tags = [
  27.                                        dict(name='div', attrs={'id':['fullPrintBodyHolder']})
  28.                         ]
  29.     remove_tags_after = [  dict(name='div', attrs={'class':'button'})]
  30.  
  31.  
  32.     remove_tags = [
  33.                     dict(name='div', attrs={'class':['url','button']})
  34.                          ]
  35.     feeds          = [
  36.                          (u'Singapore', u'http://www.todayonline.com/RSS/Singapore'),
  37.                          (u'Hot News', u'http://www.todayonline.com/RSS/Hotnews'),
  38.                         (u'Today Online', u'http://www.todayonline.com/RSS/Todayonline'),
  39.                         (u'Voices', u'http://www.todayonline.com/RSS/Voices'),
  40.                         (u'Commentary', u'http://www.todayonline.com/RSS/Commentary'),
  41.                         (u'World', u'http://www.todayonline.com/RSS/World'),
  42.                         (u'Business', u'http://www.todayonline.com/RSS/Business'),
  43.                         (u'Column', u'http://www.todayonline.com/RSS/Columns'),
  44.                       ]
  45.  
  46.     def get_obfuscated_article(self, url):
  47.         br = self.get_browser()
  48.         br.open(url)
  49.         response = br.follow_link(url_regex = r'/Print/', nr = 0)
  50.         html = response.read()
  51.         self.temp_files.append(PersistentTemporaryFile('_fa.html'))
  52.         self.temp_files[-1].write(html)
  53.         self.temp_files[-1].close()
  54.         return self.temp_files[-1].name
  55.  
  56.     def preprocess_html(self, soup):
  57.         for item in soup.findAll(style=True):
  58.            del item['style']
  59.         return soup
  60.