Beispiel #1
0
 def __init_topic(self):
     end = get_random.get_random_int(4, 5)
     for start in range(end, 0, -1):
         url = self.__topic_api.format(page=start)
         self.__driver.get(url=url)
         code_Ec = EC.presence_of_element_located((By.TAG_NAME, 'pre'))
         code: WebElement = self.__wait.until(code_Ec)
         code: Dict = analysis_json(tags=code)
         code['data_str'] = json.loads(
             base64.b64decode(code['data_str']).decode('utf-8'))
         if not code['data_str']['list']:
             continue
         for topics in code['data_str']['list']:
             if not topics['overdue']:
                 self.__topic_list.append(topics)
         if self.__topic_list:
             break
 def __do_video_task(self):
     self.__change_window_task()
     for video_task in self.__tasks['video']:
         user_msg.USER_VIDEO_PLAYING = self.__tasks['video'].index(
             video_task) + 1
         video = See_Video()
         task_url = video_task.url
         sec = get_random.get_random_int(a=0, b=9)
         video_time = VIDEO_TIME.format(sec)
         user_msg.USER_VIDEO_TIME = video_time
         video.do(task_driver=self.__driver,
                  task_url=task_url,
                  timeout=video_time)
         self.__analysis_task.update_video_see(video=video_task)
         self.__init_user_tasks()
         self.__change_window_task()
     self.__tasks['video'].clear()
 def __do_article_task(self):
     self.__change_window_task()
     for article_task in self.__tasks['article']:
         user_msg.USER_ARTICLE_PLAYING = \
             self.__tasks['article'].index(article_task) + 1
         daily_article = Daily_Article()
         task_url = article_task.url
         task_time = get_random.get_random_int(a=ARTICLE_TIME[0],
                                               b=ARTICLE_TIME[1])
         user_msg.USER_ARTICLE_TIME = task_time
         daily_article.do(task_driver=self.__driver,
                          task_url=task_url,
                          timeout=task_time)
         self.__analysis_task.update_article_see(article=article_task)
         self.__init_user_tasks()
         self.__change_window_task()
     self.__tasks['article'].clear()
Beispiel #4
0
 def __init_topic(self):
     end = get_random.get_random_int(4, 5)
     for start in range(1, end):
         url = self.__topic_api.format(page=start)
         self.__driver.get(url=url)
         code: WebElement = self.__driver.find_element_by_tag_name(
             name='pre')
         code: Dict = analysis_json(tags=code)
         code['data_str'] = json.loads(
             base64.b64decode(code['data_str']).decode('utf-8'))
         if not code['data_str']['list']:
             break
         for topics in code['data_str']['list']:
             for topic in topics['practices']:
                 if not topic['seeSolution']:
                     self.__topic_list.append(topic)
         if self.__topic_list:
             break
Beispiel #5
0
 def get_topic(self) -> int:
     topic_num: int = len(self.__topic_list)
     index: int = get_random.get_random_int(0, topic_num - 1)
     temp: Dict = self.__topic_list.pop(index)
     return temp['id']