[cuisineaz] working
This commit is contained in:
parent
743f5e8c47
commit
b0526d65a0
4 changed files with 28 additions and 42 deletions
|
|
@ -22,8 +22,6 @@ from weboob.tools.backend import BaseBackend
|
||||||
|
|
||||||
from .browser import SevenFiftyGramsBrowser
|
from .browser import SevenFiftyGramsBrowser
|
||||||
|
|
||||||
from urllib import quote_plus
|
|
||||||
|
|
||||||
__all__ = ['SevenFiftyGramsBackend']
|
__all__ = ['SevenFiftyGramsBackend']
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,6 @@ from weboob.tools.backend import BaseBackend
|
||||||
|
|
||||||
from .browser import CuisineazBrowser
|
from .browser import CuisineazBrowser
|
||||||
|
|
||||||
from urllib import quote_plus
|
|
||||||
|
|
||||||
__all__ = ['CuisineazBackend']
|
__all__ = ['CuisineazBackend']
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,49 +81,40 @@ class RecipePage(BasePage):
|
||||||
instructions = NotAvailable
|
instructions = NotAvailable
|
||||||
comments = []
|
comments = []
|
||||||
|
|
||||||
title = unicode(self.parser.select(self.document.getroot(),'head > title',1).text.split(' - ')[1])
|
title = unicode(self.parser.select(self.document.getroot(),'div#ficheRecette h1.fn.recetteH1',1).text)
|
||||||
main = self.parser.select(self.document.getroot(),'div.recette_description',1)
|
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',''))
|
||||||
|
|
||||||
rec_infos = self.parser.select(self.document.getroot(),'div.recette_infos div.infos_column strong')
|
l_spanprep = self.parser.select(main,'span.preptime')
|
||||||
for info_title in rec_infos:
|
if len(l_spanprep) > 0:
|
||||||
if u'Temps de préparation' in unicode(info_title.text):
|
preparation_time = int(l_spanprep[0].text.split()[0])
|
||||||
if info_title.tail.strip() != '':
|
l_cooktime = self.parser.select(main,'span.cooktime')
|
||||||
preparation_time = int(info_title.tail.split()[0])
|
if len(l_cooktime) > 0:
|
||||||
if 'h' in info_title.tail:
|
cooking_time = int(l_cooktime[0].text.split()[0])
|
||||||
preparation_time = 60*preparation_time
|
l_nbpers = self.parser.select(main,'td#recipeQuantity span')
|
||||||
if 'Temps de cuisson' in info_title.text:
|
if len(l_nbpers) > 0:
|
||||||
if info_title.tail.strip() != '':
|
nb_person = int(l_nbpers[0].text.split()[0])
|
||||||
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)
|
|
||||||
|
|
||||||
ingredients = []
|
ingredients = []
|
||||||
p_ing = self.parser.select(main,'div.data.top.left > div.content p')
|
l_ing = self.parser.select(main,'div#ingredients li.ingredient')
|
||||||
for ing in p_ing:
|
for ing in l_ing:
|
||||||
ingtxt = unicode(ing.text_content().strip())
|
ingtxt = unicode(ing.text_content().strip())
|
||||||
if ingtxt != '':
|
if ingtxt != '':
|
||||||
ingredients.append(ingtxt)
|
ingredients.append(ingtxt)
|
||||||
|
|
||||||
lines_instr = self.parser.select(main,'div.data.top.right div.content li')
|
instructions = u''
|
||||||
if len(lines_instr) > 0:
|
l_divinst = self.parser.select(main,'div#preparation span.instructions div')
|
||||||
instructions = u''
|
for inst in l_divinst:
|
||||||
for line in lines_instr:
|
instructions += '%s: '%inst.text
|
||||||
inst = ' '.join(line.text_content().strip().split())
|
instructions += '%s\n'%inst.getnext().text
|
||||||
instructions += '%s\n'% inst
|
|
||||||
instructions = instructions.strip('\n')
|
|
||||||
|
|
||||||
imgillu = self.parser.select(self.document.getroot(),'div.resume_recette_illustree img.photo')
|
for divcom in self.parser.select(self.document.getroot(),'div.comment'):
|
||||||
if len(imgillu) > 0:
|
author = unicode(self.parser.select(divcom,'div.commentAuthor span',1).text)
|
||||||
picture_url = unicode(imgillu[0].attrib.get('src',''))
|
date = unicode(self.parser.select(divcom,'div.commentDate',1).text)
|
||||||
|
comtxt = unicode(self.parser.select(divcom,'p',1).text_content().strip())
|
||||||
for divcom in self.parser.select(self.document.getroot(),'div.comment-outer'):
|
comments.append('author: %s, date: %s, text: %s'%(author, date, comtxt))
|
||||||
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)
|
|
||||||
|
|
||||||
recipe = Recipe(id,title)
|
recipe = Recipe(id,title)
|
||||||
recipe.preparation_time = preparation_time
|
recipe.preparation_time = preparation_time
|
||||||
|
|
|
||||||
|
|
@ -29,5 +29,4 @@ class CuisineazTest(BackendTest):
|
||||||
assert full_recipe.instructions
|
assert full_recipe.instructions
|
||||||
assert full_recipe.ingredients
|
assert full_recipe.ingredients
|
||||||
assert full_recipe.title
|
assert full_recipe.title
|
||||||
assert full_recipe.preparation_time
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue