# -*- coding: utf-8 -*-
# @Author: wangkun
# @Time: 2022/8/17
import datetime
import os
import sys
import time
sys.path.append(os.getcwd())
from main.common import Common
from main.gzh import GZH


class Main:
    @classmethod
    def main(cls, env):
        while True:
            if datetime.datetime.now().hour >= 6:
                # # 获取用户及 ID 信息
                # Common.logger('gzh').info("今日公众号抓取任务开始\n")
                # GZH.search_user_by_word('gzh')
                # 获取所有用户的公众号文章信息
                Common.logger('gzh').info("开始抓取公众号任务\n")
                GZH.get_all_gzh('gzh', env)
                # # 下载/上传
                # Common.logger('gzh').info("下载/上传\n")
                # GZH.run_download_publish('gzh', env)
                # 清除日志
                Common.del_logs('gzh')
                # 翻页初始化
                GZH.gzh_count = []
                Common.logger('gzh').info("公众号抓取任务结束，休眠{}小时\n", 24-datetime.datetime.now().hour)
                time.sleep(3600 * (24-datetime.datetime.now().hour))
            else:
                pass


if __name__ == "__main__":
    Main.main('prod')
