run_gzh_recommend.py 830 B

1234567891011121314151617181920212223242526272829303132
  1. # -*- coding: utf-8 -*-
  2. # @Author: wangkun
  3. # @Time: 2022/8/3
  4. import datetime
  5. import os
  6. import random
  7. import sys
  8. import time
  9. sys.path.append(os.getcwd())
  10. from main.gzh_recommend import Recommend
  11. from main.common import Common
  12. class Main:
  13. @classmethod
  14. def main(cls):
  15. while True:
  16. if 21 >= datetime.datetime.now().hour >= 8:
  17. # 获取列表
  18. Recommend.get_recommend_by_token("recommend")
  19. # 下载/上传
  20. Recommend.run_download_publish("recommend", "prod")
  21. # 清除日志
  22. Common.del_logs("recommend")
  23. # 随机休眠 10 - 20s
  24. Common.logger("recommend").info("随机休眠 10 - 20s")
  25. time.sleep(random.randint(10, 20))
  26. if __name__ == "__main__":
  27. Main.main()