本文整理汇总了Python中models.Comment.likes方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.likes方法的具体用法?Python Comment.likes怎么用?Python Comment.likes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Comment
的用法示例。
在下文中一共展示了Comment.likes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_comment
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import likes [as 别名]
def parse_comment(self, content, wall_owner=None):
from models import Comment
remote_id = content['id'][4:]
try:
instance = Comment.objects.get(remote_id=remote_id)
except Comment.DoesNotExist:
instance = Comment(remote_id=remote_id)
comment_text = content.find('div', {'class': 'fw_reply_text'})
if comment_text:
instance.text = comment_text.text
# date
instance.date = self.parse_container_date(content)
# likes
instance.likes = self.parse_container_likes(content, 'like_count fl_l')
# author
users = content.findAll('a', {'class': 'fw_reply_author'})
slug = users[0]['href'][1:]
if wall_owner and wall_owner.screen_name == slug:
instance.author = wall_owner
else:
avatar = content.find('a', {'class': 'fw_reply_thumb'}).find('img')['src']
name_parts = users[0].text.split(' ')
user = get_object_by_slug(slug)
if user:
user.first_name = name_parts[0]
if len(name_parts) > 1:
user.last_name = name_parts[1]
user.photo = avatar
user.save()
instance.author = user
if len(users) == 2:
# this comment is answer
slug = users[1]['href'][1:]
if wall_owner and wall_owner.screen_name == slug:
instance.reply_for = wall_owner
else:
instance.reply_for = get_object_by_slug(slug)
# имя в падеже, аватара нет
# чтобы получть текст и ID родительского коммента нужно отправить:
#http://vk.com/al_wall.php
#act:post_tt
#al:1
#post:-16297716_126263
#reply:1
instance.fetched = datetime.now()
comment_parsed.send(sender=Comment, instance=instance, raw_html=str(content))
return instance