get_like.py 483 B

123456789101112131415
  1. from lxml import etree
  2. from get_weibo_content.process_data import remove_html_tags
  3. def get_like_count(html):
  4. selector = etree.HTML(html)
  5. weibo_like_count_temp = selector.xpath('//div[@class="card-act"]/ul/li[4]/a/em')
  6. weibo_like_count = []
  7. for i in weibo_like_count_temp:
  8. temp = remove_html_tags(etree.tostring(i))
  9. if temp:
  10. weibo_like_count.append(temp)
  11. else:
  12. weibo_like_count.append('0')
  13. return weibo_like_count