diff --git a/modules/750g/backend.py b/modules/750g/backend.py index 70afea3e60807561a6fc3bd0847a03a5b42ae101..30083cdad5a50335a57850e34e55e5fff79d3baf 100644 --- a/modules/750g/backend.py +++ b/modules/750g/backend.py @@ -22,8 +22,6 @@ from .browser import SevenFiftyGramsBrowser -from urllib import quote_plus - __all__ = ['SevenFiftyGramsBackend'] diff --git a/modules/cuisineaz/backend.py b/modules/cuisineaz/backend.py index a0c067e549946453913314683e5b735908338e0c..7c2ec3560ee33ef03b342fb048134dd44f07731c 100644 --- a/modules/cuisineaz/backend.py +++ b/modules/cuisineaz/backend.py @@ -22,8 +22,6 @@ from .browser import CuisineazBrowser -from urllib import quote_plus - __all__ = ['CuisineazBackend'] diff --git a/modules/cuisineaz/pages.py b/modules/cuisineaz/pages.py index ca115fed8e53c4e27bdfaf74cf77e3eea7e5304e..0f490848c26bd5f256bbb8bdbdad7ac81db9f78e 100644 --- a/modules/cuisineaz/pages.py +++ b/modules/cuisineaz/pages.py @@ -81,49 +81,40 @@ def get_recipe(self, id): instructions = NotAvailable comments = [] - title = unicode(self.parser.select(self.document.getroot(),'head > title',1).text.split(' - ')[1]) - main = self.parser.select(self.document.getroot(),'div.recette_description',1) - - rec_infos = self.parser.select(self.document.getroot(),'div.recette_infos div.infos_column strong') - for info_title in rec_infos: - if u'Temps de préparation' in unicode(info_title.text): - if info_title.tail.strip() != '': - preparation_time = int(info_title.tail.split()[0]) - if 'h' in info_title.tail: - preparation_time = 60*preparation_time - if 'Temps de cuisson' in info_title.text: - if info_title.tail.strip() != '': - cooking_time = int(info_title.tail.split()[0]) - if 'h' in info_title.tail: - cooking_time = 60*cooking_time - if 'Nombre de personnes' in info_title.text: - if info_title.tail.strip() != '': - nb_person = int(info_title.tail) + title = unicode(self.parser.select(self.document.getroot(),'div#ficheRecette h1.fn.recetteH1',1).text) + main = self.parser.select(self.document.getroot(),'div#ficheRecette',1) + imgillu = self.parser.select(main,'div#recetteLeft img.photo') + if len(imgillu) > 0: + picture_url = unicode(imgillu[0].attrib.get('src','')) + + l_spanprep = self.parser.select(main,'span.preptime') + if len(l_spanprep) > 0: + preparation_time = int(l_spanprep[0].text.split()[0]) + l_cooktime = self.parser.select(main,'span.cooktime') + if len(l_cooktime) > 0: + cooking_time = int(l_cooktime[0].text.split()[0]) + l_nbpers = self.parser.select(main,'td#recipeQuantity span') + if len(l_nbpers) > 0: + nb_person = int(l_nbpers[0].text.split()[0]) ingredients = [] - p_ing = self.parser.select(main,'div.data.top.left > div.content p') - for ing in p_ing: + l_ing = self.parser.select(main,'div#ingredients li.ingredient') + for ing in l_ing: ingtxt = unicode(ing.text_content().strip()) if ingtxt != '': ingredients.append(ingtxt) - lines_instr = self.parser.select(main,'div.data.top.right div.content li') - if len(lines_instr) > 0: - instructions = u'' - for line in lines_instr: - inst = ' '.join(line.text_content().strip().split()) - instructions += '%s\n'% inst - instructions = instructions.strip('\n') - - imgillu = self.parser.select(self.document.getroot(),'div.resume_recette_illustree img.photo') - if len(imgillu) > 0: - picture_url = unicode(imgillu[0].attrib.get('src','')) - - for divcom in self.parser.select(self.document.getroot(),'div.comment-outer'): - comtxt = unicode(' '.join(divcom.text_content().strip().split())) - if u'| Répondre' in comtxt: - comtxt = comtxt.strip('0123456789').replace(u' | Répondre','') - comments.append(comtxt) + instructions = u'' + l_divinst = self.parser.select(main,'div#preparation span.instructions div') + for inst in l_divinst: + instructions += '%s: '%inst.text + instructions += '%s\n'%inst.getnext().text + + for divcom in self.parser.select(self.document.getroot(),'div.comment'): + author = unicode(self.parser.select(divcom,'div.commentAuthor span',1).text) + date = unicode(self.parser.select(divcom,'div.commentDate',1).text) + comtxt = unicode(self.parser.select(divcom,'p',1).text_content().strip()) + comments.append('author: %s, date: %s, text: %s'%(author, date, comtxt)) recipe = Recipe(id,title) recipe.preparation_time = preparation_time diff --git a/modules/cuisineaz/test.py b/modules/cuisineaz/test.py index ff97427c4094586863689bbbf07d6e0ef16cf02b..6bc491712af702b608ebdae77a8f9e415190f1d9 100644 --- a/modules/cuisineaz/test.py +++ b/modules/cuisineaz/test.py @@ -29,5 +29,4 @@ def test_recipe(self): assert full_recipe.instructions assert full_recipe.ingredients assert full_recipe.title - assert full_recipe.preparation_time