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

  1. from calibre.web.feeds.news import BasicNewsRecipe
  2. import re
  3.  
  4. class DrawAndCook(BasicNewsRecipe):
  5.     title               = 'DrawAndCook'
  6.     __author__          = 'Starson17'
  7.     __version__         = 'v1.10'
  8.     __date__            = '13 March 2011'
  9.     description         = 'Drawings of recipes!'
  10.     language            = 'en'
  11.     publisher           = 'Starson17'
  12.     category            = 'news, food, recipes'
  13.     use_embedded_content= False
  14.     no_stylesheets      = True
  15.     oldest_article      = 24
  16.     remove_javascript   = True
  17.     remove_empty_feeds    = True
  18.     cover_url           = 'http://farm5.static.flickr.com/4043/4471139063_4dafced67f_o.jpg'
  19.     INDEX = 'http://www.theydrawandcook.com'
  20.     max_articles_per_feed = 30
  21.  
  22.     remove_attributes = ['style', 'font']
  23.  
  24.     def parse_index(self):
  25.         feeds = []
  26.         for title, url in [
  27.                             ("They Draw and Cook", "http://www.theydrawandcook.com/")
  28.                             ]:
  29.             articles = self.make_links(url)
  30.             if articles:
  31.                 feeds.append((title, articles))
  32.         print 'feeds are: ', feeds
  33.         return feeds
  34.  
  35.     def make_links(self, url):
  36.         soup = self.index_to_soup(url)
  37.         title = ''
  38.         date = ''
  39.         current_articles = []
  40.         soup = self.index_to_soup(url)
  41.         featured_major_slider = soup.find(name='div', attrs={'id':'featured_major_slider'})
  42.         recipes = featured_major_slider.findAll('li', attrs={'data-id': re.compile(r'artwork_entry_\d+', re.DOTALL)})
  43.         for recipe in recipes:
  44.             page_url = self.INDEX + recipe.a['href']
  45.             print 'page_url is: ', page_url
  46.             title = recipe.find('strong').string
  47.             print 'title is: ', title
  48.             current_articles.append({'title': title, 'url': page_url, 'description':'', 'date':date})
  49.         return current_articles
  50.  
  51.     keep_only_tags     = [dict(name='h1', attrs={'id':'page_title'})
  52.                          ,dict(name='section', attrs={'id':'artwork'})
  53.                          ]
  54.  
  55.     remove_tags = [dict(name='article', attrs={'id':['recipe_actions', 'metadata']})
  56.                   ]
  57.  
  58.     extra_css = '''
  59.                     h1{font-family:Arial,Helvetica,sans-serif; font-weight:bold;font-size:large;}
  60.                     h2{font-family:Arial,Helvetica,sans-serif; font-weight:normal;font-size:small;}
  61.                     img {max-width:100%; min-width:100%;}
  62.                     p{font-family:Arial,Helvetica,sans-serif;font-size:small;}
  63.                     body{font-family:Helvetica,Arial,sans-serif;font-size:small;}
  64.         '''
  65.  
  66.