run_gzh.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # -*- coding: utf-8 -*-
  2. # @Author: wangkun
  3. # @Time: 2022/8/17
  4. import datetime
  5. import os
  6. import sys
  7. # import time
  8. sys.path.append(os.getcwd())
  9. from main.common import Common
  10. # from main.gzh import GZH
  11. from main.gzh_new import GZH
  12. class Main:
  13. # @classmethod
  14. # def main(cls, env):
  15. # while True:
  16. # if 20 >= datetime.datetime.now().hour >= 8:
  17. # # 获取所有用户的公众号文章信息
  18. # Common.logger('gzh').info("开始抓取公众号任务\n")
  19. # GZH.search_user_by_word('gzh')
  20. # GZH.get_all_gzh('gzh', env)
  21. # # 清除日志
  22. # Common.del_logs('gzh')
  23. # # 翻页初始化
  24. # GZH.gzh_count = []
  25. # Common.logger('gzh').info("公众号抓取任务结束,休眠{}小时\n", 24-datetime.datetime.now().hour)
  26. # time.sleep(3600 * (24-datetime.datetime.now().hour))
  27. # else:
  28. # pass
  29. @classmethod
  30. def main_new(cls, env):
  31. while True:
  32. if 22 >= datetime.datetime.now().hour >= 8:
  33. # 获取所有用户的公众号文章信息
  34. Common.logger('gzh').info("开始抓取公众号任务\n")
  35. GZH.search_user_by_word('gzh', env)
  36. # 清除日志
  37. Common.del_logs('gzh')
  38. # 翻页初始化
  39. GZH.gzh_count = []
  40. Common.logger('gzh').info("公众号抓取任务结束\n")
  41. # Common.logger('gzh').info("公众号抓取任务结束,休眠{}小时\n", 24-datetime.datetime.now().hour)
  42. # time.sleep(3600 * (24-datetime.datetime.now().hour))
  43. else:
  44. pass
  45. if __name__ == "__main__":
  46. Main.main_new('prod')