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

  1. from calibre.web.feeds.news import BasicNewsRecipe
  2. from calibre.ebooks.BeautifulSoup import BeautifulSoup
  3.  
  4. class stuffconz(BasicNewsRecipe):
  5.     title          = u'stuff.co.nz'
  6.     language       = 'en_NZ'
  7.     __author__     = 'Krittika Goyal'
  8.     oldest_article = 1 #days
  9.     max_articles_per_feed = 25
  10.     #encoding = 'latin1'
  11.  
  12.     remove_stylesheets = True
  13.     #remove_tags_before = dict(name='h1', attrs={'class':'heading'})
  14.     remove_tags_after  = dict(name='div', attrs={'id':'related_box'})
  15.     remove_tags = [
  16.        dict(name='iframe'),
  17.        dict(name='div', attrs={'class':['story_feature_title']}),
  18.        dict(name='div', attrs={'id':['toolbox', 'related_box', 'adSTORYBODY']}),
  19.        dict(name='span', attrs={'class':['related_link', 'slideshowcontrols']}),
  20.        #dict(name='ul', attrs={'class':'articleTools'}),
  21.     ]
  22.  
  23.     feeds          = [
  24. ('Dominion Post',
  25.  'http://www.stuff.co.nz/rss/dominion-post'),
  26. ('National',
  27.  'http://www.stuff.co.nz/rss/national'),
  28. ('World',
  29.  'http://www.stuff.co.nz/rss/world'),
  30. ('Business',
  31.  'http://www.stuff.co.nz/rss/business'),
  32. ('Technology',
  33.  'http://www.stuff.co.nz/rss/technology'),
  34. ('Sport',
  35.  'http://www.stuff.co.nz/rss/sport'),
  36. ('Entertainment',
  37.  'http://www.stuff.co.nz/rss/entertainment'),
  38. ('Life and Style',
  39.  'http://www.stuff.co.nz/rss/life-style'),
  40.  
  41. ]
  42.  
  43.     def preprocess_html(self, soup):
  44.         story = soup.find(name='div', attrs={'id':'left_col'})
  45.         #td = heading.findParent(name='td')
  46.         #td.extract()
  47.         soup = BeautifulSoup('<html><head><title>t</title></head><body></body></html>')
  48.         body = soup.find(name='body')
  49.         body.insert(0, story)
  50.         return soup
  51.