1
from gourmet import convert
4
sys.path.append(os.path.split(os.path.split(__file__)[0])[0])
6
from html_helpers import *
8
SUPPORTED_URLS = ['www.recipezaar.com']
9
SUPPORTED_URLS_REGEXPS = []
11
recipezaar_group = None
13
# UNICODE was causing some nasty hanging w/ recipezaar...
14
NON_UNICODE_NUMBER_REGEXP = '([\d/]([\d/ ]*[\d])?)'
16
def recipezaar_ingredient_parser (text, tag):
17
global recipezaar_group
19
if recipezaar_group: ret['inggroup']=recipezaar_group
20
grouptag = tag.fetch('td',{'colspan':'3'})
21
# And groups are in <h4> tags
22
if grouptag: grouptag = grouptag[0].fetch('h4')
24
recipezaar_group = html_importer.get_text(grouptag[0])
26
keytag = tag.fetch('span','food')
29
ret['ingkey'] = html_importer.get_text(keytag)
30
amttag = tag.fetch('td','amt')
33
ret['amount'] = html_importer.get_text(amttag)
34
ret['text'] = ret.get('amt','')+' '+html_importer.get_text(tag.fetch('td')[-1])
35
ret['text'] = ret['text'].strip()
36
ret['text'] = re.sub('\s+',' ',ret['text'])
37
print 'ingparser',text,'->',ret
40
def cut_title (title, tagname):
41
"""Cut recipe # from title
43
Title's are often followed by the recipezaar recipe # which we
46
i = title.find(' Recipe #')
60
'attributes':{'class':'submitter'},
69
'attributes':{'alt':'Recipe Photo'}}],
74
'attributes':{'name':'scaleto'}}],
78
'attributes':{'class':'recipetext'},
83
'attributes':{'class':'ingredients'}},
87
recipezaar_ingredient_parser,
90
#[{'regexp':'%(num)s+\s+servings?'%{'num':convert.NUMBER_REGEXP}}],
92
'attributes':{'id':'servings'}},
94
'attributes':{'class':'qty'}},
97
('(%(num)s+).+'%{'num':'[\d/]'},True)],
100
'attributes':{'id':'time'},
107
'attributes':{'id':'time'},
110
'attributes':{'class':'prep'},
114
('(.*)\s+prep',False),
118
'attributes':{'class':'recipetext'},
125
'attributes':{'class':'steps'},
131
'attributes':{'id':'recipecats'},},
142
'attributes':{'id':'recipecats'},},