LikeNum.py 615 B

123456789101112131415161718
  1. from lxml import etree
  2. from .ProcessTool import html_unicode_2_chinese, process_str, remove_html_tags
  3. def get_like_count(html):
  4. selector = etree.HTML(html)
  5. wei_bo_like_count_temp = selector.xpath(
  6. '//div[@class="card-act"]/ul/li[3]/a/button/span[2]')
  7. wei_bo_like_count = []
  8. for i in wei_bo_like_count_temp:
  9. temp = remove_html_tags(etree.tostring(i))
  10. temp = html_unicode_2_chinese(temp)
  11. temp = process_str(temp)
  12. if temp == '赞':
  13. wei_bo_like_count.append('0')
  14. else:
  15. wei_bo_like_count.append(temp)
  16. return wei_bo_like_count