def Get_Task_Bar(self) -> None: """ Get_Task_Bar() -> None 获取任务进度 :return: None """ while True: try: html = REQUESTS().Get(url=API().Task_Bar.geturl(), cookies=self.__cookie) data = html.json() for rule in data['data']['dayScoreDtos']: task = self.__info.Task_Bar.get(rule['ruleId']) if not task: ruleId = rule['ruleId'] name = rule['name'] desc = rule['desc'] currentScore = rule['currentScore'] dayMaxScore = rule['dayMaxScore'] task = TASK_INFO(ruleId=ruleId, name=name, desc=desc, currentScore=currentScore, dayMaxScore=dayMaxScore) else: task.Current_Score = rule['currentScore'] self.__info.Update_Task_Bar_Info(task_info=task) break except TypeError: continue
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
def Get_Daily_Score(self) -> None: """ Get_Daily_Score() -> None 获取每日积分 :return: None """ while True: try: html = REQUESTS().Get(url=API().Daily_Score.geturl(), cookies=self.__cookie) data = html.json() self.__info.Daily_Score = data['data']['score'] break except TypeError: continue
def _Init_Info(self) -> None: """ _Init_Info() -> None 初始化用户id :return: None """ while True: try: html = REQUESTS().Get(url=API().Aggregate_Score.geturl(), cookies=self.__cookie) data = html.json() self.__info.User_Id = data['data']['userId'] break except TypeError: continue
def Get_Level(self) -> None: """ Get_Level() -> None 获取等级 :return: None """ while True: try: html = REQUESTS().Get(url=API().Level.geturl(), cookies=self.__cookie) data = html.json() self.__info.Level = data['data']['level'] self.__info.Level_Name = data['data']['levelName'] self.__info.Rank_Accumulate_In_Country = \ data['data']['rankAccumulateInCountry'] break except TypeError: continue