run_weixinzhishu_hot_search.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # -*- coding: utf-8 -*-
  2. # @Author: wangkun
  3. # @Time: 2023/3/31
  4. import os
  5. import sys
  6. from threading import Thread
  7. sys.path.append(os.getcwd())
  8. from common.common import Common
  9. from weixinzhishu.weixinzhishu_hot_search.weixinzhishu_hot_search import HotSearch
  10. class Main:
  11. @classmethod
  12. def thread_baidu(cls, log_type, crawler, env):
  13. # Common.logger(log_type, crawler).info(f'开始抓取"百度热搜榜"')
  14. HotSearch.baidu_hot_search(log_type, crawler, env)
  15. # Common.logger(log_type, crawler).info(f'"百度热搜榜"抓取完毕\n')
  16. @classmethod
  17. def thread_kuaishou(cls, log_type, crawler, env):
  18. # Common.logger(log_type, crawler).info(f'开始抓取"快手热搜榜"')
  19. HotSearch.kuaishou_hot_search(log_type, crawler, env)
  20. # Common.logger(log_type, crawler).info(f'"快手热搜榜"抓取完毕\n')
  21. @classmethod
  22. def thread_douyin(cls, log_type, crawler, env):
  23. # Common.logger(log_type, crawler).info(f'开始抓取"抖音热搜榜"')
  24. HotSearch.douyin_hot_search(log_type, crawler, env)
  25. # Common.logger(log_type, crawler).info(f'"快手热搜榜"抓取完毕\n')
  26. @classmethod
  27. def thread_weixin(cls, log_type, crawler, env):
  28. # Common.logger(log_type, crawler).info(f'开始抓取"微信热搜榜"')
  29. HotSearch.weixin_hot_search(log_type, crawler, env)
  30. # Common.logger(log_type, crawler).info(f'"微信热搜榜"抓取完毕\n')
  31. @classmethod
  32. def thread_weibo(cls, log_type, crawler, env):
  33. # Common.logger(log_type, crawler).info(f'开始抓取"微博热搜榜"')
  34. HotSearch.weibo_hot_search(log_type, crawler, env)
  35. # Common.logger(log_type, crawler).info(f'"微博热搜榜"抓取完毕\n')
  36. @classmethod
  37. def thread_main(cls, log_type, crawler, env):
  38. Common.logger(log_type, crawler).info("开始抓取今日热搜榜\n")
  39. thread_baidu = Thread(target=cls.thread_baidu, args=(log_type, crawler, env))
  40. thread_kuaishou = Thread(target=cls.thread_kuaishou, args=(log_type, crawler, env))
  41. thread_douyin = Thread(target=cls.thread_douyin, args=(log_type, crawler, env))
  42. thread_weixin = Thread(target=cls.thread_weixin, args=(log_type, crawler, env))
  43. thread_weibo = Thread(target=cls.thread_weibo, args=(log_type, crawler, env))
  44. thread_baidu.start()
  45. thread_kuaishou.start()
  46. thread_douyin.start()
  47. thread_weixin.start()
  48. thread_weibo.start()
  49. thread_baidu.join()
  50. thread_kuaishou.join()
  51. thread_douyin.join()
  52. thread_weixin.join()
  53. thread_weibo.join()
  54. Common.logger(log_type, crawler).info("今日热搜榜全部抓取完毕\n")
  55. if __name__ == "__main__":
  56. Main.thread_main("hot-search", "weixinzhishu", "prod")
  57. pass