weixin_search.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. """
  2. @author: luojunhui
  3. """
  4. import json
  5. import requests
  6. from applications.functions.common import sensitive_flag
  7. def wx_search(keys, sensitive_words):
  8. """
  9. WeChat search
  10. :param sensitive_words:
  11. :param keys:
  12. :return:
  13. """
  14. return []
  15. # url = "http://8.217.190.241:8888/crawler/wei_xin/keyword"
  16. # payload = json.dumps({
  17. # "keyword": keys,
  18. # "cursor": "0",
  19. # "content_type": "video"
  20. # })
  21. # headers = {
  22. # 'Content-Type': 'application/json'
  23. # }
  24. # response = requests.request("POST", url, headers=headers, data=payload).json()
  25. # if response['msg'] == '未知错误':
  26. # return []
  27. # else:
  28. # L = []
  29. # if response['data']:
  30. # video_list = response['data']['data']
  31. # if video_list:
  32. # for video in video_list:
  33. # try:
  34. # video_info = video['items'][0]
  35. # title = video_info['title']
  36. # duration_str = video_info['duration']
  37. # dr = int(duration_str.split(":")[0].strip()) + int(duration_str.split(":")[1].strip())
  38. # if sensitive_flag(sensitive_words, title) and dr <= 300:
  39. # L.append(video_info)
  40. # else:
  41. # continue
  42. # except:
  43. # pass
  44. # return L