Exemplo n.º 1
0
    def Task_Options(cls, hint: str = None) -> None:
        """
        Task_Options() -> None
        任务选项初始化

        :return: None
        """
        OPTIONS().Task_Option_Set_Off_All()
        print("可选任务:")
        print("0、全选\t", end='')
        for key, value in OPTIONS().Task_Options.items():
            print(f"{key}、{value}\t", end='')
        print(hint if hint else '')
        options = input("选择任务(空为退出):").strip()
        if not options:
            Quit.Quit()
            exit(code=0)
        try:
            options = set([int(x) for x in options.split()])
            if 0 in options:
                OPTIONS().Task_Option_Set_On_All()
                return None
            if options - set(OPTIONS().Task_Options.keys()):
                cls.Task_Options(hint="\n请输入规定的选项序号")
            for seq in options:
                OPTIONS().Task_Option_Set_On(seq=seq)
        except ValueError:
            cls.Task_Options(hint="\n请输入数字")
Exemplo n.º 2
0
    def __Headless(cls) -> None:
        """
        __Headless() -> None
        显示过程选项(默认: False)

        :return: None
        """
        headless = input('是否显示自动化过程(y/N):').strip()
        if headless in ['y', 'Y']:
            OPTIONS().Headless = False
        else:
            OPTIONS().Headless = True
Exemplo n.º 3
0
    def __Token(cls) -> None:
        """
        __Token() -> None
        持久化选项(默认:True)

        :return: None
        """
        token = input('是否持久化登录(Y/n):').strip()
        if token in ['y', 'Y', '']:
            OPTIONS().Token = True
        else:
            OPTIONS().Token = False
Exemplo n.º 4
0
    def __Check_Options(self) -> None:
        """
        __Check_Options() -> None
        检查选项,根据选项初始化配置文件

        :return: None
        """
        temp = []
        if OPTIONS().Mute_Audio:
            self.__config['goog:chromeOptions']['args'].append("--mute-audio")
        if OPTIONS().Headless:
            self.__config['goog:chromeOptions']['args'].append("--headless")
Exemplo n.º 5
0
    def __Auto(cls) -> None:
        """
        __Auto() -> None
        禁音选项(默认: True)

        :return: None
        """
        auto = input('是否静音(Y/n):').strip()
        if auto in ['y', 'Y', '']:
            OPTIONS().Mute_Audio = True
        else:
            OPTIONS().Mute_Audio = False
    def Task_Options(cls, hint: str = None) -> None:
        """
        Task_Options() -> None
        任务选项初始化

        :return: None
        """
        OPTIONS().Task_Option_Set_Off_All()
        print("可选任务:")
        print("0、全选\t", end='')
        for key, value in OPTIONS().Task_Options.items():
            print(f"{key}、{value}\t", end='')
        print(hint if hint else '')
        OPTIONS().Task_Option_Set_On_All()
        return None
    def __Token(cls) -> None:
        """
        __Token() -> None
        持久化选项(默认:True)

        :return: None
        """
        OPTIONS().Token = True
    def __Headless(cls) -> None:
        """
        __Headless() -> None
        显示过程选项(默认: False)

        :return: None
        """
        OPTIONS().Headless = True
    def __Auto(cls) -> None:
        """
        __Auto() -> None
        禁音选项(默认: True)

        :return: True
        """
        OPTIONS().Mute_Audio = True
Exemplo n.º 10
0
    def Task(self) -> None:
        """
        Task() -> None
        根据选项执行相应的任务

        :return: None
        """
        if OPTIONS().Article:
            self.__Check_Article()
        if OPTIONS().Video:
            self.__Check_Video()
        if OPTIONS().Daily_Answer:
            self.__Check_Daily_Answer()
        if OPTIONS().Weekly_Answer:
            self.__Check_Weekly_Answer()
        if OPTIONS().Project_Answer:
            self.__Check_Project_Answer()
    def __Baidu_AI(cls) -> None:
        """
        __Baidu_AI() -> None
        百度AI选项(默认:False)

        Returns: None

        """
        OPTIONS().Baidu_AI = True
Exemplo n.º 12
0
    def __Baidu_AI(cls) -> None:
        """
        __Baidu_AI() -> None
        百度AI选项(默认:False)

        Returns: None

        """
        baidu_ai = input('是否使用百度AI(y/N):').strip()
        if baidu_ai in ['y', 'Y']:
            OPTIONS().Baidu_AI = True
            BAIDU_AI_MANAGE.Verify()
            with open(PATH().Baidu_AI_On, 'w', encoding='utf-8') as f:
                f.write("1")
                f.close()
        else:
            OPTIONS().Baidu_AI = False
            with open(PATH().Baidu_AI_On, 'w', encoding='utf-8') as f:
                f.write("0")
                f.close()
Exemplo n.º 13
0
 def _Login(self) -> bool:
     """
     _Login() -> Bool
     进行登录;
     具体流程:
         1、开启循环检测二维码状态
             1、获取二维码图片
             2、显示二维码
             3、二维码状态检测
             4、根据3的返回值决定:
                 1、刷新二维码,中断本次循环,再来一次
                 2、提取Token值,根据选项(持久化)决定是否保持token,关闭二维码容器
     :return: Bool,返回值只有True,如未登录则会一直循环
     """
     self.__network.Clear()
     self.__driver.get(url=API().Login.geturl())
     while True:
         qr = self.__Get_QR()
         QR_VESSEL().Show_QR(qr=qr)
         status = self.__Check_Status()
         if not status:
             self.__QR_Refresh()
             continue
         else:
             while self.__driver.current_url != API().Master.geturl():
                 continue
             cookies = self.__driver.get_cookies()
             token = [{cookie['name']: cookie['value']} for cookie in
                      cookies if cookie['name'] == 'token']
             if token:
                 INFO_MANAGE().Init(token=token[0]['token'])
                 if OPTIONS().Token:
                     cookie = token[0]
                     html = REQUESTS().Get(
                         url=API().Aggregate_Score.geturl(),
                         cookies=cookie
                     )
                     data = html.json()
                     user_id = data['data']['userId']
                     user = USER(user_id=user_id, token=token[0]['token'])
                     if DB_MANAGE().User.Exist_User(user=user):
                         DB_MANAGE().User.Update(user=user)
                     else:
                         DB_MANAGE().User.Insert(user=user)
                         DB_MANAGE().Article.Update_All()
                         DB_MANAGE().Video.Update_All()
             QR_VESSEL().QR_QUIT()
             return status