get_mid.py 292 B

123456789101112
  1. from lxml import etree
  2. def get_mid(html):
  3. selector = etree.HTML(html)
  4. weibo_mid = selector.xpath('//div[@class="card-wrap"]')
  5. weibo_mid_str = []
  6. for i in weibo_mid:
  7. temp = i.get("mid")
  8. if temp:
  9. weibo_mid_str.append(temp)
  10. return weibo_mid_str