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

  1. import re
  2. from calibre.web.feeds.news import BasicNewsRecipe
  3. from calibre.ebooks.BeautifulSoup import Tag
  4.  
  5. class AdvancedUserRecipe1268409464(BasicNewsRecipe):
  6.     title = u'The Sun'
  7.     __author__ = 'Chaz Ralph'
  8.     description = 'News from The Sun'
  9.     oldest_article = 1
  10.     max_articles_per_feed = 100
  11.     language = 'en'
  12.     no_stylesheets = True
  13.     extra_css = '.headline {font-size: x-large;} \n .fact { padding-top: 10pt }'
  14.     encoding= 'iso-8859-1'
  15.     remove_javascript = True
  16.  
  17.     keep_only_tags = [
  18.             dict(id='column-print')
  19.     ]
  20.  
  21.     remove_tags = [
  22.         dict(name='div', attrs={'class':[
  23.             'clear text-center small padding-left-right-5 text-999 padding-top-5 padding-bottom-10 grey-solid-line',
  24.             'clear width-625 bg-fff padding-top-10'
  25.             ]}),
  26.         dict(name='video'),
  27.     ]
  28.  
  29.     def preprocess_html(self, soup):
  30.         h1 = soup.find('h1')
  31.         if h1 is not None:
  32.             text = self.tag_to_string(h1)
  33.             nh = Tag(soup, 'h1')
  34.             nh.insert(0, text)
  35.             h1.replaceWith(nh)
  36.  
  37.         return soup
  38.  
  39.  
  40.     feeds = [(u'News', u'http://www.thesun.co.uk/sol/homepage/feeds/rss/article312900.ece')
  41. ,(u'Sport', u'http://www.thesun.co.uk/sol/homepage/feeds/rss/article247732.ece')
  42. ,(u'Football', u'http://www.thesun.co.uk/sol/homepage/feeds/rss/article247739.ece')
  43. ,(u'Gizmo', u'http://www.thesun.co.uk/sol/homepage/feeds/rss/article247829.ece')
  44. ,(u'Bizarre', u'http://www.thesun.co.uk/sol/homepage/feeds/rss/article247767.ece')]
  45.  
  46.     def print_version(self, url):
  47.         return re.sub(r'\?OTC-RSS&ATTR=[-a-zA-Z]+', '?print=yes', url)
  48.  
  49.  
  50.