コード例 #1
0
ファイル: mydriver.py プロジェクト: Windstarry/TechXueXi
 def radio_check(self, check_options):
     opts = self.driver.find_elements_by_class_name("choosable")
     for check_option in check_options:
         try:
             # self.driver.find_element_by_xpath(
             #     '//*[@id="app"]/div/div[*]/div/div[*]/div[*]/div[*]/div[contains(text(), "' + check_option + '.")]').click()
             for opt in opts:
                 if opt.text[0] == check_option:
                     opt.click()
         except Exception as e:
             print("点击", check_option, '失败!')
     self.check_delay()
     submit = WebDriverWait(
         self.driver,
         15).until(lambda driver: driver.find_element_by_class_name(
             "action-row").find_elements_by_xpath("button"))
     if len(submit) > 1:
         self.click_xpath(
             '//*[@id="app"]/div/div[2]/div/div[6]/div[2]/button[2]')
         print("成功点击交卷!")
     else:
         self.click_xpath(
             '//*[@id="app"]/div/div[*]/div/div[*]/div[*]/button')
         print("点击进入下一题")
     time.sleep(1)
     if self.driver.find_elements_by_class_name("nc-mask-display"):
         # self.swiper_valid()
         # print("出现滑块验证。")
         gl.pushprint("出现滑块验证,本次答题结束")
         raise Exception("出现滑块验证。")
コード例 #2
0
ファイル: mydriver.py プロジェクト: xuhn/TechXueXi
 def sendmsg(self):
     qcbase64=self.getQRcode()
     if gl.pushmode=="3":
         ft=FangtangHandler(gl.accesstoken)
         ft.ftmsgsend(qcbase64)
     elif gl.pushmode=="4":
         push=PlusPushHandler(gl.accesstoken)
         push.ftmsgsend(qcbase64)
     gl.pushprint(decode_img(qcbase64))
コード例 #3
0
ファイル: score.py プロジェクト: qingsudanya/TechXueXi
def get_score(cookies):
    chat_id = None
    th_name = threading.current_thread().name
    if "开始学xi" in th_name:
        chat_id = th_name[:th_name.index("开始学xi")]
    requests.adapters.DEFAULT_RETRIES = 5
    jar = RequestsCookieJar()
    for cookie in cookies:
        jar.set(cookie['name'], cookie['value'])
    total_json = requests.get("https://pc-api.xuexi.cn/open/api/score/get", cookies=jar,
                              headers={'Cache-Control': 'no-cache'}).content.decode("utf8")
    if not json.loads(total_json)["data"]:
        globalvar.pushprint("cookie过期,请重新登录", chat_id)
        if chat_id:
            remove_cookie(chat_id)
        raise

    total = int(json.loads(total_json)["data"]["score"])
    #userId = json.loads(total_json)["data"]["userId"]
    user_info = requests.get("https://pc-api.xuexi.cn/open/api/user/info", cookies=jar,
                             headers={'Cache-Control': 'no-cache'}).content.decode("utf8")
    userId = json.loads(user_info)["data"]["uid"]
    userName = json.loads(user_info)["data"]["nick"]
    # score_json = requests.get("https://pc-api.xuexi.cn/open/api/score/today/queryrate", cookies=jar,
    #                          headers={'Cache-Control': 'no-cache'}).content.decode("utf8")
    # today_json = requests.get("https://pc-api.xuexi.cn/open/api/score/today/query", cookies=jar,
    #                          headers={'Cache-Control': 'no-cache'}).content.decode("utf8")
    today = 0
    # today = int(json.loads(today_json)["data"]["score"])
    score_json = requests.get("https://pc-proxy-api.xuexi.cn/api/score/days/listScoreProgress?sence=score&deviceType=2", cookies=jar,
                              headers={'Cache-Control': 'no-cache'}).content.decode("utf8")
    dayScoreDtos = json.loads(score_json)["data"]
    today = dayScoreDtos["totalScore"]
    rule_list = [1, 2, 9, 1002, 1003, 6, 5, 4]
    score_list = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]  # 长度为十
    for i in dayScoreDtos["taskProgress"]:
        for j in range(len(rule_list)):
            if str(rule_list[j]) in i["taskCode"]:
                score_list[j] = int(
                    int(i["currentScore"])/len(i["taskCode"]))
    # 阅读文章,视听学 xi ,登录,文章时长,视听学 xi 时长,每日答题,每周答题,专项答题
    scores = {}
    scores["article_num"] = score_list[0]  # 0阅读文章
    scores["video_num"] = score_list[1]  # 1视听学 xi
    scores["login"] = score_list[2]  # 7登录
    scores["article_time"] = score_list[3]  # 6文章时长
    scores["video_time"] = score_list[4]  # 5视听学 xi 时长
    scores["daily"] = score_list[5]  # 2每日答题
    scores["weekly"] = score_list[6]  # 3每周答题
    scores["zhuanxiang"] = score_list[7]  # 4专项答题

    scores["today"] = today         # 8今日得分
    return userId, total, scores, userName
コード例 #4
0
ファイル: score.py プロジェクト: qingsudanya/TechXueXi
def show_scorePush(cookies, chat_id=None):
    userId, total, scores, userName = get_score(cookies)
    globalvar.pushprint(userName+" 当前学 xi 总积分:" + str(total) + "\t" + "今日得分:" + str(scores["today"]) +
                        "\n阅读文章:" + handle_score_color(scores["article_num"], const.article_num_all, False) + "," +
                        "观看视频:" + handle_score_color(scores["video_num"], const.video_num_all, False) + "," +
                        "文章时长:" + handle_score_color(scores["article_time"], const.article_time_all, False) + "," +
                        "视频时长:" + handle_score_color(scores["video_time"], const.video_time_all, False) + "," +
                        "\n每日登陆:" + handle_score_color(scores["login"], const.login_all, False) + "," +
                        "每日答题:" + handle_score_color(scores["daily"], const.daily_all, False) + "," +
                        "每周答题:" + handle_score_color(scores["weekly"], const.weekly_all, False) + "," +
                        "专项答题:" + handle_score_color(scores["zhuanxiang"], const.zhuanxiang_all, False), chat_id)
    return total, scores
コード例 #5
0
ファイル: mydriver.py プロジェクト: Windstarry/TechXueXi
 def sendmsg(self, chat_id=None):
     qcbase64 = self.getQRcode()
     # 发送二维码
     gl.send_qrbase64(qcbase64)
     # 发送链接
     qrurl = ''
     if gl.scheme:
         qrurl = gl.scheme + quote_plus(decode_img(qcbase64))
     else:
         qrurl = decode_img(qcbase64)
     gl.pushprint(qrurl, chat_id)
     return qrurl, qcbase64
コード例 #6
0
ファイル: pandalearning.py プロジェクト: Windstarry/TechXueXi
def start(nick_name=None):
    nohead, lock, stime, Single = get_argv()
    info_shread = threads.MyThread("获取更新信息...", version.up_info)
    info_shread.start()
    user_list = user.list_user(printing=False)
    user.refresh_all_cookies()
    if len(user_list) == 0:
        user_list.append(["", "新用户"])
    for i in range(len(user_list)):
        try:
            if nick_name == None or nick_name == user_list[i][
                    1] or nick_name == user_list[i][0]:
                _learn = threads.MyThread(user_list[i][0] + "开始学xi",
                                          start_learn,
                                          user_list[i][0],
                                          user_list[i][1],
                                          lock=Single)
                _learn.start()
        except:
            gl.pushprint("学习页面崩溃,学习终止")
コード例 #7
0
ファイル: pandalearning.py プロジェクト: Windstarry/TechXueXi
def add_user(chat_id=None):
    get_argv()
    gl.pushprint("请登录(登录方式请仔细阅读文档,如果觉得这是让你下载,就是你没仔细读文档):", chat_id=chat_id)
    driver_login = Mydriver()
    cookies = driver_login.login(chat_id)
    driver_login.quit()
    if not cookies:
        gl.pushprint("登录超时。", chat_id=chat_id)
        return
    user.save_cookies(cookies)
    uid = user.get_userId(cookies)
    user_fullname = user.get_fullname(uid)
    user.update_last_user(uid)
    gl.pushprint(user_fullname + "登录成功", chat_id=chat_id)
コード例 #8
0
def start_learn(uid, name):
    nohead, lock, stime = get_argv()
    print("是否无头模式:{0} {1}".format(nohead, os.getenv('Nohead')))
    cookies = user.get_cookie(uid)
    if nohead == True:
        TechXueXi_mode = "3"
    else:
        try:
            if cfg["base"]["ModeType"]:
                print("默认选择模式:" + str(cfg["base"]["ModeType"]) + "\n" +
                      "=" * 60)
                TechXueXi_mode = str(cfg["base"]["ModeType"])
        except Exception as e:
            TechXueXi_mode = "3"
    if not name:
        user_fullname = user.get_fullname(uid)
    else:
        user_fullname = uid + "_" + name
    if not cookies or TechXueXi_mode == "0":
        msg = ""
        if name == "新用户":
            msg = "需要增加新用户,请扫码登录,否则请无视"
        else:
            msg = user_fullname + "登录信息失效,请重新扫码"
        print(msg)
        gl.pushprint(msg)
        driver_login = Mydriver()
        cookies = driver_login.login()
        driver_login.quit()
        if not cookies:
            print("登录超时")
            return
        user.save_cookies(cookies)
        uid = user.get_userId(cookies)
        user_fullname = user.get_fullname(uid)
        user.update_last_user(uid)
    output = "\n用户:" + user_fullname + "登录正常,开始学习...\n"

    article_index = user.get_article_index(uid)
    video_index = 1  # user.get_video_index(uid)

    total, scores = show_score(cookies)
    gl.pushprint(output)
    if TechXueXi_mode in ["1", "3"]:

        article_thread = threads.MyThread("文章学 xi ",
                                          article,
                                          uid,
                                          cookies,
                                          article_index,
                                          scores,
                                          lock=lock)
        video_thread = threads.MyThread("视频学 xi ",
                                        video,
                                        uid,
                                        cookies,
                                        video_index,
                                        scores,
                                        lock=lock)
        article_thread.start()
        video_thread.start()
        article_thread.join()
        video_thread.join()
    if TechXueXi_mode in ["2", "3"]:
        driver_default = Mydriver()
        print('开始每日答题……')
        daily(cookies, scores, driver_default=driver_default)
        if TechXueXi_mode in ["2", "3"]:
            print('开始每周答题……')
            weekly(cookies, scores, driver_default=driver_default)
            if nohead != True:
                print('开始专项答题……')
                zhuanxiang(cookies, scores, driver_default=driver_default)
        try:
            driver_default.quit()
        except Exception as e:
            gl.pushprint('driver_default 在 main 退出时出了一点小问题...')
    if TechXueXi_mode == "4":
        user.select_user()
    if TechXueXi_mode == "5":
        user.refresh_all_cookies(display_score=True)
    if TechXueXi_mode == "6":
        user.refresh_all_cookies(live_time=11.90)

    seconds_used = int(time.time() - start_time)
    print("总计用时 " + str(math.floor(seconds_used / 60)) + " 分 " +
          str(seconds_used % 60) + " 秒")
    show_scorePush(cookies)
    try:
        user.shutdown(stime)
    except Exception as e:
        pass
コード例 #9
0
ファイル: pandalearning.py プロジェクト: snowasnow/TechXueXi
    if not cookies or TechXueXi_mode == "0":
        print("未找到有效登录信息,需要登录")
        driver_login = Mydriver()
        cookies = driver_login.login()
        driver_login.quit()
        user.save_cookies(cookies)
        uid = user.get_userId(cookies)
        user_fullname = user.get_fullname(uid)
        user.update_last_user(uid)
    # 增加多用户支持,已经有登录信息的重新扫码
    else:
        user_fullname = user.get_fullname(uid)
        output = "\n用户" + user_fullname + "已登录,如要再次学习请重新扫码\n"
        print(output)
        gl.pushprint(output)
        driver_login = Mydriver()
        cookies = driver_login.login()
        driver_login.quit()
        user.save_cookies(cookies)
        uid = user.get_userId(cookies)
        user.update_last_user(uid)
    output = "\n用户:" + user_fullname + "登录正常,开始学习...\n"

    article_index = user.get_article_index(uid)
    video_index = 1  # user.get_video_index(uid)

    total, scores = show_score(cookies)
    gl.pushprint(output)
    if TechXueXi_mode in ["1", "3"]:
コード例 #10
0
ファイル: pandalearning.py プロジェクト: Windstarry/TechXueXi
def start_learn(uid, name):
    #  0 读取版本信息
    start_time = time.time()
    nohead, lock, stime, Single = get_argv()
    print("是否无头模式:{0} {1}".format(nohead, os.getenv('Nohead')))
    cookies = user.get_cookie(uid)
    if nohead == True:
        TechXueXi_mode = "3"
    else:
        TechXueXi_mode = str(cfg_get("base.ModeType", 3))
        print("当前选择模式:" + TechXueXi_mode + "\n" + "=" * 60)

    if not name:
        user_fullname = user.get_fullname(uid)
        name = user_fullname.split('_', 1)[1]
    else:
        user_fullname = uid + "_" + name

    if not cookies or TechXueXi_mode == "0":
        msg = ""
        if name == "新用户":
            msg = "需要增加新用户,请扫码登录,否则请无视"
        else:
            msg = name + " 登录信息失效,请重新扫码"
        # print(msg)
        gl.pushprint(msg, chat_id=uid)
        if gl.pushmode == "6":
            gl.pushprint("web模式跳过自动获取二维码,请手动点击添加按钮", chat_id=uid)
            print(color.red("【#️⃣】 若直接退出请运行:webserverListener.py"))
            return
        driver_login = Mydriver()
        cookies = driver_login.login()
        driver_login.quit()
        if not cookies:
            print("登录超时")
            return
        user.save_cookies(cookies)
        uid = user.get_userId(cookies)
        user_fullname = user.get_fullname(uid)
        name = user_fullname.split('_', 1)[1]
        user.update_last_user(uid)
    output = name + " 登录正常,开始学习...\n"

    article_index = user.get_article_index(uid)
    video_index = 1  # user.get_video_index(uid)

    total, scores = show_score(cookies)
    gl.pushprint(output, chat_id=uid)
    if TechXueXi_mode in ["1", "3"]:

        article_thread = threads.MyThread("文章学 xi ",
                                          article,
                                          uid,
                                          cookies,
                                          article_index,
                                          scores,
                                          lock=lock)
        video_thread = threads.MyThread("视频学 xi ",
                                        video,
                                        uid,
                                        cookies,
                                        video_index,
                                        scores,
                                        lock=lock)
        article_thread.start()
        video_thread.start()
        article_thread.join()
        video_thread.join()
    if TechXueXi_mode in ["2", "3"]:
        print('开始每日答题……')
        daily(cookies, scores)
        print('开始每周答题……')
        weekly(cookies, scores)
        if nohead != True or gl.zhuanxiang == True:
            print('开始专项答题……')
            zhuanxiang(cookies, scores)

    if TechXueXi_mode == "4":
        user.select_user()
    if TechXueXi_mode == "5":
        user.refresh_all_cookies(display_score=True)
    if TechXueXi_mode == "6":
        user.refresh_all_cookies(live_time=11.90)

    seconds_used = int(time.time() - start_time)
    gl.pushprint(name + " 总计用时 " + str(math.floor(seconds_used / 60)) + " 分 " +
                 str(seconds_used % 60) + " 秒",
                 chat_id=uid)
    show_scorePush(cookies, chat_id=uid)
    try:
        user.shutdown(stime)
    except Exception as e:
        pass
コード例 #11
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=gl.nohead)
            ##### driver_ans = Mydriver(nohead=True)
        else:
            driver_ans = driver_default
        driver_daily = driver_ans
        driver_weekly = driver_ans
        driver_zhuanxiang = driver_ans
        # try:
        #     nohead = gl.nohead
        # except:
        #     nohead=False
        # if nohead:
        #     print("使用默认窗口大小")
        # else:
        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
        # 从数据库获取答案
        answer_from_db = False
        answer_error_max = cfg_get("parameter.answer_error_max", 100)
        # 是否开启错题收集
        answer_error_collect = cfg_get("parameter.answer_error_collect", True)
        if scores[quiz_type] < score_all:
            letters = list("ABCDEFGHIJKLMN")
            driver_ans.get_url('https://pc.xuexi.cn/points/my-points.html')
            refresh_my_page_count = 0
            # 页面title为积分则一直循环
            while driver_ans.title_is(u"我的积分") and refresh_my_page_count < 20:
                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)
                refresh_my_page_count += 1
                if refresh_my_page_count >= 20:
                    print("没有找到答题按钮")
            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
                # 全局出错次数
                if max_count >= answer_error_max and globalvar.nohead == True:
                    print("略过次数已经超过" + str(answer_error_max) +
                          "次,且出于Nohead模式,退出答题")
                    break
                print(category)
                q_text = ""
                tips = []
                tip_full_text = ""
                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())
                try:
                    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)
                except Exception as e:
                    print("获取题干出错" + str(e))
                # 上次出错,则采用数据库答题
                if answer_from_db:
                    answer_from_db = False  # 下次从页面获取提示
                    try:
                        if not q_text:
                            q_body = driver_ans.driver.find_element_by_css_selector(
                                ".q-body")
                            q_html = q_body.get_attribute('innerHTML')
                            q_text = q_body.text
                        tips = search_answer(q_text)
                    except Exception as e:
                        print("数据搜索答案异常:" + str(e))
                else:
                    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("页面未找到提示,尝试从题库搜索答案。\n")
                    try:
                        answer_from_db = False  # 下次从页面获取提示
                        if not q_text:
                            q_body = driver_ans.driver.find_element_by_css_selector(
                                ".q-body")
                            q_html = q_body.get_attribute('innerHTML')
                            q_text = q_body.text
                        tips = search_answer(q_text)
                    except Exception as e:
                        print("数据搜索答案异常:" + str(e))
                if not tips:
                    print("本题没有提示")
                    max_count += 1
                    pass_count += 1

                    if pass_count >= 5:
                        print(
                            "暂时略过已达到 5 次,【 建议您将此题目的题干、提示、选项信息提交到github问题收集issue:https://github.com/TechXueXi/techxuexi-tiku/issues/1 】"
                        )
                        auto.prompt("等待用户手动答题...完成后请在此按回车...")
                        pass_count = 0
                        continue
                    # if quiz_type == "daily":
                    #     log_daily("!!!!!本题没有找到提示,暂时略过!!!!!")
                    #     auto.prompt("等待用户手动答题...完成后请在此按回车...")
                    #     time.sleep(1)
                    #     continue
                    if "填空题" in category:
                        print('没有找到提示,暂时略过')
                        # print('使用默认答案  好 ')   #如无填空答案,使用默认答案 好 字 by Sean
                        ##### tips = ['好']
                        if gl.nohead and answer_error_collect:
                            gl.push_msg += "[题干]" + q_text + '\n'
                        continue
                    elif "多选题" in category:
                        print('没有找到提示,多选题默认全选')
                        # print('使用默认答案 全选')    #by Sean
                        ## continue  #####
                        tips = driver_daily.radio_get_options()
                        if gl.nohead and answer_error_collect:
                            gl.push_msg += f"[题干]{q_text}\n[选项]{str(tips)}\n"
                    elif "单选题" in category:
                        print('没有找到提示,单选题默认选A')  # 如无单选答案,使用默认答案
                        # print('使用默认答案 B')   #by Sean
                        # continue  #####
                        # return driver_daily._search(driver_daily.content, driver_daily.options, driver_daily.excludes)
                        ops = driver_daily.radio_get_options()
                        tips = [ops[0]]
                        if gl.nohead and answer_error_collect:
                            gl.push_msg += f"[题干]{q_text}\n[选项]{str(ops)}\n"
                    else:
                        print("题目类型非法")
                        if quiz_type == "daily":
                            log_daily("!!!!!无提示,题目类型非法!!!!!")
                        break
                if tips:
                    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))
                            # and radio_in_tips not in driver_daily.excludes:
                            if len(radio_in_tips) > 1:
                                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:
                                max_count += 1
                                answer_from_db = True
                                print('无法根据提示判断,将在数据库中查询答案……')
                                log_daily("!!!!!无法根据提示判断,请自行答题……!!!!!")
                                # print('将使用默认全选答题')     #by Sean
                                ##### len_option = len(options)
                                ##### radio_in_tips = letters[:len_option]
                                # driver_daily.radio_check(radio_in_tips)
                                if not gl.nohead:
                                    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)
                            # and radio_in_tips not in driver_weekly.excludes:
                            if len(radio_in_tips) > 1:
                                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:
                                max_count += 1
                                answer_from_db = True
                                print('无法根据提示判断,将在数据库中查询答案……')
                                # print('将使用默认全选答题')     #by Sean
                                ##### len_option = len(options)
                                ##### radio_in_tips = letters[:len_option]
                                # driver_weekly.radio_check(radio_in_tips)
                                if not gl.nohead:
                                    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)
                            # and radio_in_tips not in driver_zhuanxiang.excludes:
                            if len(radio_in_tips) > 1:
                                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:
                                max_count += 1
                                answer_from_db = True
                                print('无法根据提示判断,将在数据库中查询答案……')
                                # print('将使用默认全选答题')     #by Sean
                                ##### len_option = len(options)
                                ##### radio_in_tips = letters[:len_option]
                                # driver_zhuanxiang.radio_check(radio_in_tips)
                                if not gl.nohead:
                                    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))
                                # and radio_in_tips not in driver_daily.excludes:
                                if 1 == len(radio_in_tips):
                                    print('根据提示', radio_in_tips)
                                    driver_daily.radio_check(radio_in_tips)
                                # and radio_out_tips not in excludes
                                elif 1 == len(radio_out_tips):
                                    print('根据提示', radio_out_tips)
                                    driver_daily.radio_check(radio_out_tips)
                                # return driver_daily._search(content, options, excludes)
                                else:
                                    max_count += 1
                                    answer_from_db = True
                                    print('无法根据提示判断,将在数据库中查询答案……')
                                    log_daily("!!!!!无法根据提示判断,请自行答题……!!!!!")
                                    # print('将使用默认选 B')     #by Sean
                                    ##### radio_in_tips = "B"
                                    # driver_daily.radio_check(radio_in_tips)
                                    if not gl.nohead:
                                        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)
                                # and radio_in_tips not in driver_weekly.excludes:
                                if 1 == len(radio_in_tips):
                                    print('根据提示', radio_in_tips)
                                    driver_weekly.radio_check(radio_in_tips)
                                # and radio_out_tips not in excludes
                                elif 1 == len(radio_out_tips):
                                    print('根据提示', radio_out_tips)
                                    driver_weekly.radio_check(radio_out_tips)
                                # return driver_weekly._search(content, options, excludes)
                                else:
                                    max_count += 1
                                    answer_from_db = True
                                    print('无法根据提示判断,将在数据库中查询答案……')
                                    # print('将使用默认选 B')     #by Sean
                                    ##### radio_in_tips = "B"
                                    # driver_weekly.radio_check(radio_in_tips)
                                    if not gl.nohead:
                                        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)
                                # and radio_in_tips not in driver_zhuanxiang.excludes:
                                if 1 == len(radio_in_tips):
                                    print('根据提示', radio_in_tips)
                                    driver_zhuanxiang.radio_check(
                                        radio_in_tips)
                                # and radio_out_tips not in excludes
                                elif 1 == len(radio_out_tips):
                                    print('根据提示', radio_out_tips)
                                    driver_zhuanxiang.radio_check(
                                        radio_out_tips)
                                # return driver_zhuanxiang._search(content, options, excludes)
                                else:
                                    max_count += 1
                                    answer_from_db = True
                                    print('无法根据提示判断,将在数据库中查询答案……')
                                    # print('将使用默认选 B')     #by Sean
                                    ##### radio_in_tips = "B"
                                    # driver_zhuanxiang.radio_check(radio_in_tips)
                                    if not gl.nohead:
                                        auto.prompt("等待用户手动答题...完成后请在此按回车...")
                    else:
                        print("题目类型非法")
                        if quiz_type == "daily":
                            log_daily("!!!!!有提示,但题目类型非法!!!!!")
                        break
                    time.sleep(1)
            total, scores = show_score(cookies)
            # 答题完成,并存在全局错题,进行推送
            if gl.nohead and answer_error_collect and gl.push_msg:
                gl.pushprint('')
            if scores[quiz_type] >= score_all:
                print("检测到" + quiz_zh_CN[quiz_type] + "答题分数已满,退出学 xi ")
            else:
                print(
                    "!!!!!没拿到满分,请收集日志反馈错误题目!!!!!https://github.com/TechXueXi/techxuexi-tiku/issues/1"
                )
                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] + "答题已满分.")