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("学习页面崩溃,学习终止")
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
except Exception as e: pass if __name__ == '__main__': # 0 读取版本信息 start_time = time.time() if (cfg['display']['banner'] != False): # banner文本直接硬编码,不要放在conf中 print("=" * 60 + \ '\n 科技强 guo 官方网站:https://techxuexi.js.org' + \ '\n Github地址:https://github.com/TechXueXi' + \ '\n使用本项目,必须接受以下内容,否则请立即退出:' + \ '\n - TechXueXi 仅额外提供给“爱党爱 guo ”且“工作学业繁重”的人' + \ '\n - 项目开源协议 LGPL-3.0' + \ '\n - 不得利用本项目盈利' + \ '\n另外,我们建议你参与一个维护劳动法的项目:' + \ '\nhttps://996.icu/ 或 https://github.com/996icu/996.ICU/blob/master/README_CN.md') print("=" * 60, '''\nTechXueXi 现支持以下模式(答题时请值守电脑旁处理少部分不正常的题目):''') print(cfg['base']['ModeText'] + '\n' + "=" * 60) # 模式提示文字请在 ./config/default_template.conf 处修改。 info_shread = threads.MyThread("获取更新信息...", version.up_info) info_shread.start() user_list = user.list_user(printing=False) user.refresh_all_cookies() user_list.append(["", "新用户"]) for i in range(len(user_list)): _learn = threads.MyThread(user_list[i][0] + "开始学xi", start_learn, user_list[i][0], user_list[i][1]) _learn.start()
total, each = show_score(cookies) else: break if try_count < 10: print("视频学习完成") else: print("视频学习出现异常,请检查用户名下v_log文件记录数") driver_video.quit() else: print("视频之前学完了") if __name__ == '__main__': # 0 读取版本信息 start_time = time.time() info_shread = threads.MyThread("获取更新信息...", version.up_info) info_shread.start() # 1 创建用户标记,区分多个用户历史纪录 dd_status, uname = user.get_user() cookies, a_log, v_log = user_flag(dd_status, uname) total, each = show_score(cookies) nohead, lock, stime = get_argv() article_thread = threads.MyThread("文章学习", article, cookies, a_log, each, lock=lock) video_thread = threads.MyThread("视频学习", video, cookies, v_log, each, lock=lock) article_thread.start() video_thread.start() article_thread.join() video_thread.join() print("总计用时" + str(int(time.time() - start_time) / 60) + "分钟") user.shutdown(stime)
driver_video.go_js( 'window.scrollTo(0, document.body.scrollHeight)') total, each = show_score(cookies) else: break if try_count < 10: print("视频学习完成") else: print("视频学习出现异常,请检查用户名下v_log文件记录数") driver_video.quit() else: print("视频之前学完了") if __name__ == '__main__': # 0 读取版本信息 start_time = time.time() info_shread = threads.MyThread("获取更新信息...", version.up_info) info_shread.start() # 1 创建用户标记,区分多个用户历史纪录 dd_status, uname = user.get_user() cookies, a_log, v_log = user_flag(dd_status, uname) total, each = show_score(cookies) nohead, lock, stime = get_argv() article(cookies, a_log, each) video(cookies, a_log, each) print("总计用时" + str(int(time.time() - start_time) / 60) + "分钟") user.shutdown(stime)
'\n - TechXueXi 仅额外提供给“爱党爱国”且“工作学业繁重”的人' + '\n - 项目开源协议 LGPL-3.0' + '\n - 不得利用本项目盈利' + '\n另外,我们建议你参与一个维护劳动法的项目:' + '\nhttps://996.icu/ 或 https://github.com/996icu/996.ICU/blob/master/README_CN.md' ) cookies = user.check_default_user_cookie() user.list_user() # user.select_user() print("=" * 60, '''\nTechXueXi 现支持以下模式(答题时请值守电脑旁处理少部分不正常的题目):''') print(cfg['base']['ModeText'] + '\n' + "=" * 60) # 模式提示文字请在 ./config/main.ini 处修改。 # TechXueXi_mode = input("请选择模式(输入对应数字)并回车: ") # 懒人之最版 TechXueXi_mode = cfg['base']['Mode'] info_shread = threads.MyThread("获取更新信息...", version.up_info) info_shread.start() # 1 创建用户标记,区分多个用户历史纪录 uid = user.get_default_userId() if not cookies: print("未找到有效登录信息,需要登录") driver_login = Mydriver(nohead=False) cookies = driver_login.login() user.save_cookies(cookies) uid = user.get_userId(cookies) user_fullname = user.get_fullname(uid) user.update_last_user(uid) try: driver_login.quit() except: print("wtf:退出webdriver失败?")
# lock = False if lock: print('开始今天的文章学习') article(driver_login, a_log, myscores) print('开始今天的视频学习') video(driver_login, v_log, myscores) driver_login.quit() # user.shutdown(60) else: driver_login.quit() driver_article = mydriver.Mydriver(nohead=nohead) driver_article.get_url("https://pc.xuexi.cn/points/my-points.html") driver_article.set_cookies(cookies) article_thread = threads.MyThread("文章学习", article, driver_article, a_log, myscores, lock=lock) ''' driver = driver_login.driver driver.execute_script("window.open('https://www.xuexi.cn/notFound.html')") all_handles = driver.window_handles print(all_handles) driver.switch_to_window(all_handles[1]) ''' driver_video = mydriver.Mydriver(nohead=nohead) driver_video.get_url("https://pc.xuexi.cn/points/my-points.html") driver_video.set_cookies(cookies) video_thread = threads.MyThread("视频学习", video, driver_video, v_log, myscores, lock=lock) article_thread.start() video_thread.start()
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
if __name__ == '__main__': # 0 读取版本信息 start_time = time.time() #info_shread = threads.MyThread("获取更新信息...", version.up_info) #info_shread.start() # 1 创建用户标记,区分多个用户历史纪录 dd_status, uname = user.get_user() cookies, a_log, v_log, wechat_users = user_flag(dd_status, uname) total, each = show_score(cookies) nohead, lock, stime = get_argv() article_thread = threads.MyThread("文章学习", article, cookies, a_log, wechat_users, each, lock=lock) video_thread = threads.MyThread("视频学习", video, cookies, v_log, wechat_users, each, lock=lock) article_thread.start() video_thread.start() article_thread.join() video_thread.join() print("总计用时" + str(int(time.time() - start_time) / 60) + "分钟")