Debian Codegraph @

recipes/DrawAndCook.recipe

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