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

  1. from calibre.web.feeds.news import BasicNewsRecipe
  2. from calibre.ebooks.BeautifulSoup import Tag
  3.  
  4. class AdvancedUserRecipe1282101454(BasicNewsRecipe):
  5.     title = 'BuckMasters In The Kitchen'
  6.     language = 'en'
  7.     __author__ = 'TonytheBookworm & Starson17'
  8.     description = 'Learn how to cook all those outdoor varments'
  9.     publisher = 'BuckMasters.com'
  10.     category = 'food,cooking,recipes'
  11.     oldest_article = 365
  12.     max_articles_per_feed = 100
  13.     conversion_options = {'linearize_tables' : True}
  14.     masthead_url = 'http://www.buckmasters.com/Portals/_default/Skins/BM_10/images/header_bg.jpg'
  15.     keep_only_tags    = [
  16.                          dict(name='table', attrs={'class':['containermaster_black']})
  17.                         ]
  18.     remove_tags_after = [dict(name='div', attrs={'align':['left']})]
  19.     feeds          = [
  20.                       ('Recipes', 'http://www.buckmasters.com/DesktopModules/DnnForge%20-%20NewsArticles/RSS.aspx?TabID=292&ModuleID=658&MaxCount=25'),
  21.                     ]
  22.  
  23.     def preprocess_html(self, soup):
  24.         item = soup.find('a', attrs={'class':['MenuTopSelected']})
  25.         if item:
  26.             item.parent.extract()
  27.         for img_tag in soup.findAll('img'):
  28.             parent_tag = img_tag.parent
  29.             if parent_tag.name == 'a':
  30.                 new_tag = Tag(soup,'p')
  31.                 new_tag.insert(0,img_tag)
  32.                 parent_tag.replaceWith(new_tag)
  33.             elif parent_tag.name == 'p':
  34.                 if not self.tag_to_string(parent_tag) == '':
  35.                     new_div = Tag(soup,'div')
  36.                     new_tag = Tag(soup,'p')
  37.                     new_tag.insert(0,img_tag)
  38.                     parent_tag.replaceWith(new_div)
  39.                     new_div.insert(0,new_tag)
  40.                     new_div.insert(1,parent_tag)
  41.         return soup
  42.  
  43.