예제 #1
0
def check_default_user_cookie():
    default_userId = get_default_userId()
    default_fullname = get_default_fullname()
    default_nickname = get_default_nickname()
    print_list = [color.blue(str(default_userId)),
                  color.blue(default_nickname)]
    print(
        "=" * 60, "\n默认用户ID:{0[0]},默认用户昵称:{0[1]}".format(print_list), end=" ")
    cookies = get_cookie(default_userId)
    if not cookies:
        print(color.red("【无有效cookie信息,需要登录】"))
        return []
    else:
        print(color.green("(cookie信息有效)"))
        return cookies
예제 #2
0
def list_user():
    status = get_user_status()
    mapping = status['userId_mapping']
    map_count = len(mapping)
    if (map_count > 2):
        print("检测到您有多用户:", end="")
        for i in mapping:
            print(color.blue(i + "_" + mapping[i]), end="; ")
        print("")
예제 #3
0
파일: user.py 프로젝트: DoveBoy/TechXueXi
def list_user(printing=True):
    status = get_user_status()
    mapping = status['userId_mapping']
    map_count = len(mapping)
    all_users = []
    for i in mapping:
        if i == "0":
            continue
        else:
            all_users.append([i, mapping[i]])
    if printing:
        if (map_count > 2):
            print("检测到您有多用户:", end="")
            for i in mapping:
                print(color.blue(i + "_" + mapping[i]), end="; ")
            print("")
    return all_users
예제 #4
0
파일: user.py 프로젝트: DoveBoy/TechXueXi
def select_user():
    user_list = list_user(printing=False)
    user_count = len(user_list)
    print("=" * 60)
    if user_count > 1:
        print("检测到多用户:")
        for i in range(user_count):
            print(i, " ", user_list[i][0], " ", user_list[i][1])
        num = int(input("请选择用户序号:"))
        if num < 0 or num >= user_count:
            print("输入的范围不对。")
            exit()
        else:
            user_id = user_list[num][0]
            print("默认用户已切换为:" + color.blue(get_fullname(user_id)))
            update_last_user(user_id)
    else:
        print("目前你只有一个用户。用户名:", get_default_userId(), ",昵称:",
              get_default_nickname())
예제 #5
0
파일: user.py 프로젝트: DoveBoy/TechXueXi
def refresh_all_cookies(live_time=8.0,
                        display_score=False):  # cookie有效时间保持在live_time以上
    template_json_str = '''{}'''
    cookies_json_obj = file.get_json_data("user/cookies.json",
                                          template_json_str)
    need_check = False
    valid_cookies = []
    for uid in cookies_json_obj:
        cookies_b64 = cookies_json_obj[uid]
        cookies_bytes = base64.b64decode(cookies_b64)
        cookie_list = pickle.loads(cookies_bytes)
        for d in cookie_list:  # 检查是否过期
            if 'name' in d and 'value' in d and 'expiry' in d and d[
                    "name"] == "token":
                remain_time = (int(d['expiry']) - (int)(time.time())) / 3600
                print(
                    color.green(uid + "_" + get_nickname(uid) + ",登录剩余有效时间:" +
                                str(int(remain_time * 1000) / 1000) + " 小时."),
                    end="")
                if remain_time < 0:
                    print(color.red(" 已过期 需要重新登陆,将自动移除此cookie."))
                    remove_cookie(uid)
                else:
                    # print(color.blue(" 有效"), end="")
                    valid_cookies.append(cookie_list)
                    if remain_time <= live_time:  # 全新cookies的有效时间是12h
                        print(color.red(" 需要刷新"))
                        need_check = True
                        # 暂没有证据表明可以用requests来请求,requests请求的响应不带cookies,不确定会不会更新cookies时间
                        # (但是万一服务端自动更新了cookie,可以试试12h之后再访问呢?则剩余时间直接设为12即可。有空的伙计可以做个实验)
                        # jar = RequestsCookieJar()
                        # for cookie in cookie_list:
                        #     jar.set(cookie['name'], cookie['value'])
                        # new_cookies = requests.get("https://pc.xuexi.cn/points/my-points.html", cookies=jar,
                        #                         headers={'Cache-Control': 'no-cache'}).cookies.get_dict()
                        # 浏览器登陆方式更新cookie,速度较慢但可靠
                        driver_login = Mydriver(nohead=False)
                        driver_login.get_url(
                            "https://www.xuexi.cn/notFound.html")
                        driver_login.set_cookies(cookie_list)
                        driver_login.get_url(
                            'https://pc.xuexi.cn/points/my-points.html')
                        new_cookies = driver_login.get_cookies()
                        driver_login.quit()
                        found_token = False
                        for j in new_cookies:  # 检查token
                            if 'name' in j and j["name"] == "token":
                                found_token = True
                        if not found_token:
                            remove_cookie(uid)  # cookie不含token则无效,删除cookie
                        else:
                            save_cookies(new_cookies)
                    else:
                        print(color.green(" 无需刷新"))
    if need_check:  # 再执行一遍来检查有效情况
        print("再次检查cookies有效时间...")
        refresh_all_cookies()
    elif display_score:
        for cookie in valid_cookies:
            user_id = get_userId(cookie)
            print(color.blue(get_fullname(user_id)) + " 的今日得分:")
            score.show_score(cookie)
예제 #6
0
def answer_question(quiz_type,
                    cookies,
                    scores,
                    score_all,
                    quiz_xpath,
                    category_xpath,
                    uid=None,
                    driver_default=None):
    quiz_zh_CN = {"daily": "每日", "weekly": "每周", "zhuanxiang": "专项"}
    if (quiz_type not in ["daily", "weekly", "zhuanxiang"]):
        print("quiz_type 错误。收到的quiz_type:" + quiz_type)
        exit(0)
    if uid is None:
        uid = user.get_userId(cookies)
    if scores[quiz_type] < score_all:  # 还没有满分,需要答题
        if driver_default is None:
            driver_ans = Mydriver(nohead=False)
            ##### driver_ans = Mydriver(nohead=True)
        else:
            driver_ans = driver_default
        driver_daily = driver_ans
        driver_weekly = driver_ans
        driver_zhuanxiang = driver_ans
        driver_ans.driver.maximize_window()
        print('请保持窗口最大化\n' * 3)
        driver_ans.get_url("https://www.xuexi.cn/notFound.html")
        driver_ans.set_cookies(cookies)
        pass_count = 0
        #最大值,用于nohead模式退出
        max_count = 0
        if scores[quiz_type] < score_all:
            letters = list("ABCDEFGHIJKLMN")
            driver_ans.get_url('https://pc.xuexi.cn/points/my-points.html')
            while driver_ans.title_is(u"我的积分"):  # 页面title为积分则一直循环
                time.sleep(1)  # 等待页面刷新提示
                refresh_buttons = driver_ans.driver.find_elements_by_css_selector(
                    ".ant-modal-wrap .ant-btn:not(.ant-btn-primary)")
                if len(refresh_buttons) > 0:  #
                    refresh_buttons[0].click()
                driver_ans.click_xpath(quiz_xpath)  # 点击各个题目的去答题按钮
                time.sleep(1)
            if quiz_type != "daily":  # 如果是每日答题就不用找available了
                # 此处修改是因为页面可能刷新后导致的查找元素button 丢失从而引发异常重新此处用可以重新查找来解决
                try:
                    to_click = find_available_quiz(quiz_type, driver_ans, uid)
                except Exception as e:
                    to_click = find_available_quiz(quiz_type, driver_ans, uid)
                if to_click is not None:
                    to_click.click()
                    time.sleep(0.5)
                else:
                    print(color.blue("无题可答。即将跳过。"))
                    if driver_default is None:
                        try:
                            driver_ans.quit()
                        except Exception as e:
                            print('driver_ans 在 answer_question 退出时出了一点小问题...')
                    else:
                        pass  #其他函数传入函数的driver,不自动退出
            while scores[quiz_type] < score_all:
                try:
                    category = driver_ans.xpath_getText(
                        category_xpath)  #获取题目类型 get_attribute("name")
                except Exception as e:
                    print('查找题目类型...查找元素失败!')
                    break
                print(category)
                if quiz_type == "daily":
                    ans_results = driver_ans.driver.find_elements_by_css_selector(
                        ".practice-result .infos .info")
                    if (len(ans_results) != 0):  #已经找到答题结果页面
                        print(ans_results[0].get_attribute("innerHTML"))
                        print(ans_results[0].text)
                        print(ans_results[2].get_attribute("innerHTML"))
                        print(ans_results[2].text)
                        time.sleep(1)
                        # exit(2)
                        break
                    log_daily("\n====================")
                    log_daily(log_timestamp())
                    log_daily("【" + category + "】")
                    log_daily("【题干】")
                    q_body = driver_ans.driver.find_element_by_css_selector(
                        ".q-body")
                    q_html = q_body.get_attribute('innerHTML')
                    q_text = q_body.text
                    print(q_text)
                    log_daily(q_html)
                tips, tip_full_text = driver_ans._view_tips()
                if quiz_type == "daily":
                    log_daily("【提示信息】")
                    log_daily(str(tips) + "\n" + tip_full_text)
                if not tips:
                    print("本题没有提示")
                    max_count += 1
                    pass_count += 1
                    if max_count >= 100 and globalvar.nohead == True:
                        print("略过次数已经超过100次,且出于Nohead模式,退出答题")
                        break
                    if pass_count >= 5:  #####
                        print(
                            "暂时略过已达到 5 次,【 建议您将此题目的题干、提示、选项信息提交到github问题收集issue:https://github.com/TechXueXi/TechXueXi/issues/29 】"
                        )
                        auto.prompt("等待用户手动答题...完成后请在此按回车...")
                        pass_count = 0
                    if quiz_type == "daily":  #####
                        log_daily("!!!!!本题没有找到提示,暂时略过!!!!!")
                        auto.prompt("等待用户手动答题...完成后请在此按回车...")
                        time.sleep(1)
                    if "填空题" in category:
                        print('没有找到提示,暂时略过')
                        ##### print('使用默认答案  好 ')   #如无填空答案,使用默认答案 好 字 by Sean
                        ##### tips = ['好']
                        continue  #####
                    elif "多选题" in category:
                        print('没有找到提示,暂时略过')
                        ##### print('使用默认答案 全选')    #by Sean
                        continue  #####
                    elif "单选题" in category:
                        print('没有找到提示,暂时略过')  # 如无单选答案,使用默认答案
                        ##### print('使用默认答案 B')   #by Sean
                        continue  #####
                        # return driver_daily._search(driver_daily.content, driver_daily.options, driver_daily.excludes)
                    else:
                        print("题目类型非法")
                        if quiz_type == "daily":
                            log_daily("!!!!!无提示,题目类型非法!!!!!")
                        break
                else:
                    if "填空题" in category:
                        answer = tips
                        if quiz_type != "zhuanxiang":
                            driver_ans.fill_in_blank(answer)
                        else:
                            driver_ans.zhuanxiang_fill_in_blank(answer)
                    elif "多选题" in category:
                        if quiz_type == "daily":
                            options = driver_daily.radio_get_options()
                            ##### len_option = len(options)
                            log_daily("【多选题选项】")
                            log_daily(str(options))
                            radio_in_tips, radio_out_tips = "", ""
                            for letter, option in zip(letters, options):
                                for tip in tips:
                                    if tip in option:
                                        # print(f'{option} in tips')
                                        if letter not in radio_in_tips:
                                            radio_in_tips += letter
                            radio_out_tips = [
                                letter
                                for letter, option in zip(letters, options)
                                if (letter not in radio_in_tips)
                            ]

                            print('包含提示的选项 ', radio_in_tips, ',不包含提示的选项 ',
                                  radio_out_tips)
                            log_daily('包含提示的选项 ' + str(radio_in_tips) +
                                      ',不包含提示的选项 ' + str(radio_out_tips))
                            if len(
                                    radio_in_tips
                            ) > 1:  # and radio_in_tips not in driver_daily.excludes:
                                print('根据提示', radio_in_tips)
                                driver_daily.radio_check(radio_in_tips)
                            elif len(
                                    radio_out_tips
                            ) > 1:  # and radio_out_tips not in excludes
                                print('根据提示', radio_out_tips)
                                driver_daily.radio_check(radio_out_tips)
                            # return driver_daily._search(content, options, excludes)
                            else:
                                print('无法根据提示判断,请自行答题……')
                                log_daily("!!!!!无法根据提示判断,请自行答题……!!!!!")
                                ##### print('将使用默认全选答题')     #by Sean
                                ##### len_option = len(options)
                                ##### radio_in_tips = letters[:len_option]
                                ##### driver_daily.radio_check(radio_in_tips)
                                auto.prompt("等待用户手动答题...完成后请在此按回车...")
                        elif quiz_type == "weekly":
                            options = driver_weekly.radio_get_options()
                            radio_in_tips, radio_out_tips = "", ""
                            for letter, option in zip(letters, options):
                                for tip in tips:
                                    if tip in option:
                                        # print(f'{option} in tips')
                                        if letter not in radio_in_tips:
                                            radio_in_tips += letter
                            radio_out_tips = [
                                letter
                                for letter, option in zip(letters, options)
                                if (letter not in radio_in_tips)
                            ]

                            print('含 ', radio_in_tips, '不含', radio_out_tips)
                            if len(
                                    radio_in_tips
                            ) > 1:  # and radio_in_tips not in driver_weekly.excludes:
                                print('根据提示', radio_in_tips)
                                driver_weekly.radio_check(radio_in_tips)
                            elif len(
                                    radio_out_tips
                            ) > 1:  # and radio_out_tips not in excludes
                                print('根据提示', radio_out_tips)
                                driver_weekly.radio_check(radio_out_tips)
                            # return driver_weekly._search(content, options, excludes)
                            else:
                                print('无法根据提示判断,请自行准备搜索……')
                                ##### print('将使用默认全选答题')     #by Sean
                                ##### len_option = len(options)
                                ##### radio_in_tips = letters[:len_option]
                                ##### driver_weekly.radio_check(radio_in_tips)
                                auto.prompt("等待用户手动答题...完成后请在此按回车...")
                        elif quiz_type == "zhuanxiang":
                            options = driver_zhuanxiang.radio_get_options()
                            radio_in_tips, radio_out_tips = "", ""
                            for letter, option in zip(letters, options):
                                for tip in tips:
                                    if tip in option:
                                        # print(f'{option} in tips')
                                        if letter not in radio_in_tips:
                                            radio_in_tips += letter
                            radio_out_tips = [
                                letter
                                for letter, option in zip(letters, options)
                                if (letter not in radio_in_tips)
                            ]

                            print('含 ', radio_in_tips, '不含', radio_out_tips)
                            if len(
                                    radio_in_tips
                            ) > 1:  # and radio_in_tips not in driver_zhuanxiang.excludes:
                                print('根据提示', radio_in_tips)
                                driver_zhuanxiang.radio_check(radio_in_tips)
                            elif len(
                                    radio_out_tips
                            ) > 1:  # and radio_out_tips not in excludes
                                print('根据提示', radio_out_tips)
                                driver_zhuanxiang.radio_check(radio_out_tips)
                            # return driver_zhuanxiang._search(content, options, excludes)
                            else:
                                print('无法根据提示判断,请自行准备搜索……')
                                ##### print('将使用默认全选答题')     #by Sean
                                ##### len_option = len(options)
                                ##### radio_in_tips = letters[:len_option]
                                ##### driver_zhuanxiang.radio_check(radio_in_tips)
                                auto.prompt("等待用户手动答题...完成后请在此按回车...")
                    elif "单选题" in category:
                        if quiz_type == "daily":
                            options = driver_daily.radio_get_options()
                            log_daily("【单选题选项】")
                            log_daily(str(options))
                            if '因此本题选' in tips:  #提示类型1
                                check = [x for x in letters if x in tips]
                                log_daily("根据提示类型1,选择答案:" + str(check))
                                driver_daily.radio_check(check)
                            else:
                                radio_in_tips, radio_out_tips = "", ""
                                '''
                                option_elements = driver_daily.wait.until(driver_daily.EC.presence_of_all_elements_located(
                                    (driver_daily.By.XPATH, '//*[@id="app"]/div/div[2]/div/div[4]/div[1]')))
                                # option_elements = self.find_elements(rules['challenge_options'])
                                options = [x.get_attribute("name") for x in option_elements]'''
                                for letter, option in zip(letters, options):
                                    for tip in tips:
                                        if tip in option:
                                            # print(f'{option} in tips')
                                            if letter not in radio_in_tips:
                                                radio_in_tips += letter
                                        else:
                                            # print(f'{option} out tips')
                                            if letter not in radio_out_tips:
                                                radio_out_tips += letter

                                print('包含提示的选项 ', radio_in_tips, ',不包含提示的选项 ',
                                      radio_out_tips)
                                log_daily('包含提示的选项 ' + str(radio_in_tips) +
                                          ',不包含提示的选项 ' + str(radio_out_tips))
                                if 1 == len(
                                        radio_in_tips
                                ):  # and radio_in_tips not in driver_daily.excludes:
                                    print('根据提示', radio_in_tips)
                                    driver_daily.radio_check(radio_in_tips)
                                elif 1 == len(
                                        radio_out_tips
                                ):  # and radio_out_tips not in excludes
                                    print('根据提示', radio_out_tips)
                                    driver_daily.radio_check(radio_out_tips)
                                # return driver_daily._search(content, options, excludes)
                                else:
                                    print('无法根据提示判断,请自行答题……')
                                    log_daily("!!!!!无法根据提示判断,请自行答题……!!!!!")
                                    ##### print('将使用默认选 B')     #by Sean
                                    ##### radio_in_tips = "B"
                                    ##### driver_daily.radio_check(radio_in_tips)
                                    auto.prompt("等待用户手动答题...完成后请在此按回车...")
                        elif quiz_type == "weekly":
                            options = driver_weekly.radio_get_options()
                            if '因此本题选' in tips:
                                check = [x for x in letters if x in tips]
                                driver_weekly.radio_check(check)
                            else:
                                radio_in_tips, radio_out_tips = "", ""
                                '''
                                option_elements = driver_weekly.wait.until(driver_weekly.EC.presence_of_all_elements_located(
                                    (driver_weekly.By.XPATH, '//*[@id="app"]/div/div[2]/div/div[4]/div[1]')))
                                # option_elements = self.find_elements(rules['challenge_options'])
                                options = [x.get_attribute("name") for x in option_elements]'''
                                for letter, option in zip(letters, options):
                                    for tip in tips:
                                        if tip in option:
                                            # print(f'{option} in tips')
                                            if letter not in radio_in_tips:
                                                radio_in_tips += letter
                                        else:
                                            # print(f'{option} out tips')
                                            if letter not in radio_out_tips:
                                                radio_out_tips += letter

                                print('含 ', radio_in_tips, '不含',
                                      radio_out_tips)
                                if 1 == len(
                                        radio_in_tips
                                ):  # and radio_in_tips not in driver_weekly.excludes:
                                    print('根据提示', radio_in_tips)
                                    driver_weekly.radio_check(radio_in_tips)
                                elif 1 == len(
                                        radio_out_tips
                                ):  # and radio_out_tips not in excludes
                                    print('根据提示', radio_out_tips)
                                    driver_weekly.radio_check(radio_out_tips)
                                # return driver_weekly._search(content, options, excludes)
                                else:
                                    print('无法根据提示判断,请自行准备搜索……')
                                    ##### print('将使用默认选 B')     #by Sean
                                    ##### radio_in_tips = "B"
                                    ##### driver_weekly.radio_check(radio_in_tips)
                                    auto.prompt("等待用户手动答题...完成后请在此按回车...")
                        elif quiz_type == "zhuanxiang":
                            options = driver_zhuanxiang.radio_get_options()
                            if '因此本题选' in tips:
                                check = [x for x in letters if x in tips]
                                driver_zhuanxiang.radio_check(check)
                            else:
                                radio_in_tips, radio_out_tips = "", ""
                                '''
                                option_elements = driver_zhuanxiang.wait.until(driver_zhuanxiang.EC.presence_of_all_elements_located(
                                    (driver_zhuanxiang.By.XPATH, '//*[@id="app"]/div/div[2]/div/div[4]/div[1]')))
                                # option_elements = self.find_elements(rules['challenge_options'])
                                options = [x.get_attribute("name") for x in option_elements]'''
                                for letter, option in zip(letters, options):
                                    for tip in tips:
                                        if tip in option:
                                            # print(f'{option} in tips')
                                            if letter not in radio_in_tips:
                                                radio_in_tips += letter
                                        else:
                                            # print(f'{option} out tips')
                                            if letter not in radio_out_tips:
                                                radio_out_tips += letter

                                print('含 ', radio_in_tips, '不含',
                                      radio_out_tips)
                                if 1 == len(
                                        radio_in_tips
                                ):  # and radio_in_tips not in driver_zhuanxiang.excludes:
                                    print('根据提示', radio_in_tips)
                                    driver_zhuanxiang.radio_check(
                                        radio_in_tips)
                                elif 1 == len(
                                        radio_out_tips
                                ):  # and radio_out_tips not in excludes
                                    print('根据提示', radio_out_tips)
                                    driver_zhuanxiang.radio_check(
                                        radio_out_tips)
                                # return driver_zhuanxiang._search(content, options, excludes)
                                else:
                                    print('无法根据提示判断,请自行准备搜索……')
                                    ##### print('将使用默认选 B')     #by Sean
                                    ##### radio_in_tips = "B"
                                    ##### driver_zhuanxiang.radio_check(radio_in_tips)
                                    auto.prompt("等待用户手动答题...完成后请在此按回车...")
                    else:
                        print("题目类型非法")
                        if quiz_type == "daily":
                            log_daily("!!!!!有提示,但题目类型非法!!!!!")
                        break
                    time.sleep(1)
            total, scores = show_score(cookies)
            if scores[quiz_type] >= score_all:
                print("检测到" + quiz_zh_CN[quiz_type] + "答题分数已满,退出学 xi ")
            else:
                print("!!!!!没拿到满分,请收集日志反馈错误题目!!!!!")
                auto.prompt("完成后(或懒得弄)请在此按回车...")
                #log_daily("!!!!!没拿到满分!!!!!")
        if driver_default == None:
            try:
                driver_ans.quit()
            except Exception as e:
                print('driver_ans 在 answer_question 退出时出了一点小问题...')
        else:
            pass  #其他函数传入函数的driver,不自动退出
    else:
        print(quiz_zh_CN[quiz_type] + "答题已满分.")
예제 #7
0
def answer_question(quiz_type,
                    cookies,
                    scores,
                    score_all,
                    quiz_xpath,
                    category_xpath,
                    uid=None,
                    driver_default=None):
    quiz_zh_CN = {"daily": "每日", "weekly": "每周", "zhuanxiang": "专项"}
    if (quiz_type not in ["daily", "weekly", "zhuanxiang"]):
        print("quiz_type 错误。收到的quiz_type:" + quiz_type)
        exit(0)
    if uid is None:
        uid = user.get_userId(cookies)
    if scores[quiz_type] < score_all:  # 还没有满分,需要答题
        if driver_default is None:
            driver_ans = Mydriver(nohead=False)
        else:
            driver_ans = driver_default

        driver_daily = driver_ans
        driver_weekly = driver_ans
        driver_zhuanxiang = driver_ans
        driver_ans.driver.maximize_window()

        print('请保持窗口最大化\n' * 3)
        driver_ans.get_url("https://www.xuexi.cn/notFound.html")
        driver_ans.set_cookies(cookies)
        try_count = 0
        if scores[quiz_type] < score_all:
            letters = list("ABCDEFGHIJKLMN")
            driver_ans.get_url('https://pc.xuexi.cn/points/my-points.html')

            driver_ans.click_xpath(quiz_xpath)  # 点击各个题目的去答题按钮
            time.sleep(2)
            if quiz_type != "daily":  # 如果是每日答题就不用找available了
                to_click = find_available_quiz(quiz_type, driver_ans, uid)
                if to_click is not None:
                    to_click.click()
                    time.sleep(0.5)
                else:
                    print(color.blue("无题可答。即将跳过。"))
                    if driver_default == None:
                        try:
                            driver_ans.quit()
                        except Exception as e:
                            print('driver_ans 在 answer_question 退出时出了一点小问题...')
                    else:
                        pass  #其他函数传入函数的driver,不自动退出

            while scores[quiz_type] < score_all:
                if quiz_type == "weekly":
                    '''# 
                    # =======
                    #            flag = 1
                    #            page_num = 1
                    #            last_page = int(driver_weekly.driver.find_element_by_xpath('//*[@id="app"]/div/div[2]/div/div[5]/ul/li[last()-1]/a').text)
                    #            while page_num < last_page and flag == 1:
                    #                print('进入每周答题第'+ str(page_num) +'页')
                    #                all_month = len(driver_weekly.driver.find_elements_by_class_name('month'))
                    #                cur_month = 1
                    #                for tem in range(0, all_month):
                    #                    for tem2 in range(0, 6):
                    #                        if flag == 0:
                    #                            break
                    #                        try:
                    #                            temword = driver_weekly.driver.find_element_by_xpath(
                    #                                '//*[@id="app"]/div/div[2]/div/div[4]/div/div[' + str(tem + 1) + ']/div[2]/div[' + str(
                    #                                    tem2 + 1) + ']/button').text
                    #                        except:
                    #                            temword = ''
                    #                            if all_month == cur_month:
                    #                                driver_weekly.click_xpath(
                    #                                        '//*[@id="app"]/div/div[2]/div/div[5]/ul/li[' + str(page_num + 2) + ']')
                    #                                print('切换至下一页')
                    #                                page_num += 1
                    #                                time.sleep(2)
                    #                            cur_month += 1
                    #                            break
                    #                        name_list = ["开始答题", "继续答题"]
                    #                        if flag == 1 and (any(name in temword for name in name_list)):
                    #                            driver_weekly.click_xpath(
                    #                                '//*[@id="app"]/div/div[2]/div/div[4]/div/div[' + str(tem + 1) + ']/div[2]/div[' + str(
                    #                                    tem2 + 1) + ']/button')
                    #                            flag = 0
                    #                        elif '重新答题' in temword:
                    #                            continue
                    #            while each[6] < 5 and try_count < 10:
                    # >>>>>>> dev
                    # '''
                try:
                    category = driver_ans.xpath_getText(  #获取题目类型
                        category_xpath)  # get_attribute("name")
                except Exception as e:
                    print('查找题目类型...查找元素失败!')
                    break
                print(category)
                if quiz_type == "daily":
                    ans_results = driver_ans.driver.find_elements_by_css_selector(
                        ".practice-result .infos .info")
                    if (len(ans_results) != 0):  #已经找到答题结果页面
                        print(ans_results[0].get_attribute("innerHTML"))
                        print(ans_results[0].text)
                        print(ans_results[2].get_attribute("innerHTML"))
                        print(ans_results[2].text)

                        time.sleep(3)
                        # exit(2)
                        break

                    log_daily("\n====================")
                    log_daily(log_timestamp())
                    log_daily("【" + category + "】")
                    log_daily("【题干】")
                    q_body = driver_ans.driver.find_element_by_css_selector(
                        ".q-body")
                    q_html = q_body.get_attribute('innerHTML')
                    q_text = q_body.text
                    print(q_text)
                    log_daily(q_html)
                tips, tip_full_text = driver_ans._view_tips()
                if quiz_type == "daily":
                    log_daily("【提示信息】")
                    log_daily(str(tips) + "\n" + tip_full_text)
                if not tips:
                    print("本题没有提示")
                    if quiz_type == "daily":
                        log_daily("!!!!!本题没有找到提示,暂时略过!!!!!")

                        input("等待用户手动答题...完成后请在此按回车...")
                        time.sleep(3)

                    if "填空题" in category:
                        print('没有找到提示,暂时略过')
                        continue
                    elif "多选题" in category:
                        print('没有找到提示,暂时略过')
                        continue
                    elif "单选题" in category:
                        print('没有找到提示,暂时略过')
                        continue
                        # return driver_daily._search(driver_daily.content, driver_daily.options, driver_daily.excludes)
                    else:
                        print("题目类型非法")
                        if quiz_type == "daily":
                            log_daily("!!!!!无提示,题目类型非法!!!!!")
                        break
                else:
                    if "填空题" in category:
                        answer = tips
                        if quiz_type != "zhuanxiang":
                            driver_ans.fill_in_blank(answer)
                        else:
                            driver_ans.zhuanxiang_fill_in_blank(answer)
                    elif "多选题" in category:
                        if quiz_type == "daily":
                            options = driver_daily.radio_get_options()
                            log_daily("【多选题选项】")
                            log_daily(str(options))
                            radio_in_tips, radio_out_tips = "", ""
                            for letter, option in zip(letters, options):
                                for tip in tips:
                                    if tip in option:
                                        # print(f'{option} in tips')
                                        if letter not in radio_in_tips:
                                            radio_in_tips += letter
                            radio_out_tips = [
                                letter
                                for letter, option in zip(letters, options)
                                if (letter not in radio_in_tips)
                            ]

                            print('包含提示的选项 ', radio_in_tips, ',不包含提示的选项 ',
                                  radio_out_tips)
                            log_daily('包含提示的选项 ' + str(radio_in_tips) +
                                      ',不包含提示的选项 ' + str(radio_out_tips))
                            if len(
                                    radio_in_tips
                            ) > 1:  # and radio_in_tips not in driver_daily.excludes:
                                print('根据提示', radio_in_tips)
                                driver_daily.radio_check(radio_in_tips)
                            elif len(
                                    radio_out_tips
                            ) > 1:  # and radio_out_tips not in excludes
                                print('根据提示', radio_out_tips)
                                driver_daily.radio_check(radio_out_tips)
                            # return driver_daily._search(content, options, excludes)
                            else:
                                print('无法根据提示判断,请自行答题……')
                                log_daily("!!!!!无法根据提示判断,请自行答题……!!!!!")

                                input("等待用户手动答题...完成后请在此按回车...")

                        elif quiz_type == "weekly":
                            options = driver_weekly.radio_get_options()
                            radio_in_tips, radio_out_tips = "", ""
                            for letter, option in zip(letters, options):
                                for tip in tips:
                                    if tip in option:
                                        # print(f'{option} in tips')
                                        if letter not in radio_in_tips:
                                            radio_in_tips += letter
                            radio_out_tips = [
                                letter
                                for letter, option in zip(letters, options)
                                if (letter not in radio_in_tips)
                            ]

                            print('含 ', radio_in_tips, '不含', radio_out_tips)
                            if len(
                                    radio_in_tips
                            ) > 1:  # and radio_in_tips not in driver_weekly.excludes:
                                print('根据提示', radio_in_tips)
                                driver_weekly.radio_check(radio_in_tips)
                            elif len(
                                    radio_out_tips
                            ) > 1:  # and radio_out_tips not in excludes
                                print('根据提示', radio_out_tips)
                                driver_weekly.radio_check(radio_out_tips)
                            # return driver_weekly._search(content, options, excludes)
                            else:

                                print('无法根据提示判断,请自行准备搜索……')
                                input("等待用户手动答题...完成后请在此按回车...")

                        elif quiz_type == "zhuanxiang":
                            options = driver_zhuanxiang.radio_get_options()
                            radio_in_tips, radio_out_tips = "", ""
                            for letter, option in zip(letters, options):
                                for tip in tips:
                                    if tip in option:
                                        # print(f'{option} in tips')
                                        if letter not in radio_in_tips:
                                            radio_in_tips += letter
                            radio_out_tips = [
                                letter
                                for letter, option in zip(letters, options)
                                if (letter not in radio_in_tips)
                            ]

                            print('含 ', radio_in_tips, '不含', radio_out_tips)
                            if len(
                                    radio_in_tips
                            ) > 1:  # and radio_in_tips not in driver_zhuanxiang.excludes:
                                print('根据提示', radio_in_tips)
                                driver_zhuanxiang.radio_check(radio_in_tips)
                            elif len(
                                    radio_out_tips
                            ) > 1:  # and radio_out_tips not in excludes
                                print('根据提示', radio_out_tips)
                                driver_zhuanxiang.radio_check(radio_out_tips)
                            # return driver_zhuanxiang._search(content, options, excludes)
                            else:

                                print('无法根据提示判断,请自行准备搜索……')
                                input("等待用户手动答题...完成后请在此按回车...")

                    elif "单选题" in category:
                        if quiz_type == "daily":
                            options = driver_daily.radio_get_options()
                            log_daily("【单选题选项】")
                            log_daily(str(options))
                            if '因此本题选' in tips:  #提示类型1
                                check = [x for x in letters if x in tips]
                                log_daily("根据提示类型1,选择答案:" + str(check))
                                driver_daily.radio_check(check)
                            else:
                                radio_in_tips, radio_out_tips = "", ""
                                '''
                                option_elements = driver_daily.wait.until(driver_daily.EC.presence_of_all_elements_located(
                                    (driver_daily.By.XPATH, '//*[@id="app"]/div/div[2]/div/div[4]/div[1]')))
                                # option_elements = self.find_elements(rules['challenge_options'])
                                options = [x.get_attribute("name") for x in option_elements]'''
                                for letter, option in zip(letters, options):
                                    for tip in tips:
                                        if tip in option:
                                            # print(f'{option} in tips')
                                            if letter not in radio_in_tips:
                                                radio_in_tips += letter
                                        else:
                                            # print(f'{option} out tips')
                                            if letter not in radio_out_tips:
                                                radio_out_tips += letter

                                print('包含提示的选项 ', radio_in_tips, ',不包含提示的选项 ',
                                      radio_out_tips)
                                log_daily('包含提示的选项 ' + str(radio_in_tips) +
                                          ',不包含提示的选项 ' + str(radio_out_tips))
                                if 1 == len(
                                        radio_in_tips
                                ):  # and radio_in_tips not in driver_daily.excludes:
                                    print('根据提示', radio_in_tips)
                                    driver_daily.radio_check(radio_in_tips)
                                elif 1 == len(
                                        radio_out_tips
                                ):  # and radio_out_tips not in excludes
                                    print('根据提示', radio_out_tips)
                                    driver_daily.radio_check(radio_out_tips)
                                # return driver_daily._search(content, options, excludes)
                                else:
                                    print('无法根据提示判断,请自行答题……')
                                    log_daily("!!!!!无法根据提示判断,请自行答题……!!!!!")

                                    input("等待用户手动答题...完成后请在此按回车...")

                        elif quiz_type == "weekly":
                            options = driver_weekly.radio_get_options()
                            if '因此本题选' in tips:
                                check = [x for x in letters if x in tips]
                                driver_weekly.radio_check(check)
                            else:
                                radio_in_tips, radio_out_tips = "", ""
                                '''
                                option_elements = driver_weekly.wait.until(driver_weekly.EC.presence_of_all_elements_located(
                                    (driver_weekly.By.XPATH, '//*[@id="app"]/div/div[2]/div/div[4]/div[1]')))
                                # option_elements = self.find_elements(rules['challenge_options'])
                                options = [x.get_attribute("name") for x in option_elements]'''
                                for letter, option in zip(letters, options):
                                    for tip in tips:
                                        if tip in option:
                                            # print(f'{option} in tips')
                                            if letter not in radio_in_tips:
                                                radio_in_tips += letter
                                        else:
                                            # print(f'{option} out tips')
                                            if letter not in radio_out_tips:
                                                radio_out_tips += letter

                                print('含 ', radio_in_tips, '不含',
                                      radio_out_tips)
                                if 1 == len(
                                        radio_in_tips
                                ):  # and radio_in_tips not in driver_weekly.excludes:
                                    print('根据提示', radio_in_tips)
                                    driver_weekly.radio_check(radio_in_tips)
                                elif 1 == len(
                                        radio_out_tips
                                ):  # and radio_out_tips not in excludes
                                    print('根据提示', radio_out_tips)
                                    driver_weekly.radio_check(radio_out_tips)
                                # return driver_weekly._search(content, options, excludes)
                                else:

                                    print('无法根据提示判断,请自行准备搜索……')
                                    input("等待用户手动答题...完成后请在此按回车...")

                        elif quiz_type == "zhuanxiang":
                            options = driver_zhuanxiang.radio_get_options()
                            if '因此本题选' in tips:
                                check = [x for x in letters if x in tips]
                                driver_zhuanxiang.radio_check(check)
                            else:
                                radio_in_tips, radio_out_tips = "", ""
                                '''
                                option_elements = driver_zhuanxiang.wait.until(driver_zhuanxiang.EC.presence_of_all_elements_located(
                                    (driver_zhuanxiang.By.XPATH, '//*[@id="app"]/div/div[2]/div/div[4]/div[1]')))
                                # option_elements = self.find_elements(rules['challenge_options'])
                                options = [x.get_attribute("name") for x in option_elements]'''
                                for letter, option in zip(letters, options):
                                    for tip in tips:
                                        if tip in option:
                                            # print(f'{option} in tips')
                                            if letter not in radio_in_tips:
                                                radio_in_tips += letter
                                        else:
                                            # print(f'{option} out tips')
                                            if letter not in radio_out_tips:
                                                radio_out_tips += letter

                                print('含 ', radio_in_tips, '不含',
                                      radio_out_tips)
                                if 1 == len(
                                        radio_in_tips
                                ):  # and radio_in_tips not in driver_zhuanxiang.excludes:
                                    print('根据提示', radio_in_tips)
                                    driver_zhuanxiang.radio_check(
                                        radio_in_tips)
                                elif 1 == len(
                                        radio_out_tips
                                ):  # and radio_out_tips not in excludes
                                    print('根据提示', radio_out_tips)
                                    driver_zhuanxiang.radio_check(
                                        radio_out_tips)
                                # return driver_zhuanxiang._search(content, options, excludes)
                                else:

                                    print('无法根据提示判断,请自行准备搜索……')
                                    input("等待用户手动答题...完成后请在此按回车...")

                    else:
                        print("题目类型非法")
                        if quiz_type == "daily":
                            log_daily("!!!!!有提示,但题目类型非法!!!!!")
                        break
                    time.sleep(1)

            total, scores = show_score(cookies)
            if scores[quiz_type] >= score_all:
                print("检测到" + quiz_zh_CN[quiz_type] + "答题分数已满,退出学习")
            else:
                print("!!!!!没拿到满分,请收集日志反馈错误题目!!!!!")
                input("完成后(或懒得弄)请在此按回车...")
                #log_daily("!!!!!没拿到满分!!!!!")
        if driver_default == None:
            try:
                driver_ans.quit()
            except Exception as e:
                print('driver_ans 在 answer_question 退出时出了一点小问题...')
        else:
            pass  #其他函数传入函数的driver,不自动退出
    else:
        print(quiz_zh_CN[quiz_type] + "答题已满分.")