[cookboob] comments objectified
This commit is contained in:
parent
34a7c25cef
commit
e6fe9ed69e
4 changed files with 38 additions and 20 deletions
|
|
@ -18,7 +18,7 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.capabilities.recipe import Recipe
|
||||
from weboob.capabilities.recipe import Recipe, Comment
|
||||
from weboob.capabilities.base import NotAvailable, NotLoaded
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
|
@ -121,10 +121,13 @@ class RecipePage(BasePage):
|
|||
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)
|
||||
author = None
|
||||
if 'par ' in comtxt:
|
||||
author = comtxt.split('par ')[-1].split('|')[0]
|
||||
comtxt = comtxt.replace('par %s' % author, '')
|
||||
comments.append(Comment(text=comtxt, author=author))
|
||||
|
||||
links_author = self.parser.select(self.document.getroot(), 'p.auteur a.couleur_membre')
|
||||
print links_author[0].text.strip()
|
||||
if len(links_author) > 0:
|
||||
author = unicode(links_author[0].text.strip())
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.capabilities.recipe import Recipe
|
||||
from weboob.capabilities.recipe import Recipe, Comment
|
||||
from weboob.capabilities.base import NotAvailable, NotLoaded
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
|
@ -123,12 +123,9 @@ class RecipePage(BasePage):
|
|||
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))
|
||||
comments.append(Comment(author=author, text=comtxt))
|
||||
|
||||
spans_author = self.parser.select(self.document.getroot(), 'span.author')
|
||||
if len(spans_author) > 0:
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.capabilities.recipe import Recipe
|
||||
from weboob.capabilities.recipe import Recipe, Comment
|
||||
from weboob.capabilities.base import NotAvailable, NotLoaded
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ class RecipePage(BasePage):
|
|||
note = self.parser.select(divcom, 'div.m_commentaire_note span', 1).text.strip()
|
||||
user = self.parser.select(divcom, 'div.m_commentaire_content span', 1).text.strip()
|
||||
content = self.parser.select(divcom, 'div.m_commentaire_content p', 1).text.strip()
|
||||
comments.append(u'user: %s, note: %s, comment: %s' % (user, note, content))
|
||||
comments.append(Comment(author=user, rate=note, text=content))
|
||||
|
||||
recipe = Recipe(id, title)
|
||||
recipe.preparation_time = preparation_time
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue