Jump-Wang-111 / BIT-CourseRace

北京理工大学研究生抢课脚本,2024年1月版
MIT License
14 stars 0 forks source link

现在是2024年9月 请问还可以使用吗 #1

Open UkiTenzai opened 2 weeks ago

UkiTenzai commented 2 weeks ago

我使用的时候报错

[*] Try to catch courses out of plan...
[+] Success. Courses have been saved in ./OutPlanCourses.json
[*] Try to catch courses in plan...
[+] Success. Courses have been saved in ./InPlanCourses.json
Traceback (most recent call last):
  File "C:\Users\xxx\BIT-CourseRace-main\CourseRace.py", line 194, in <module>
    findCourse(args.courseID)
  File "C:\Users\xxx\BIT-CourseRace-main\CourseRace.py", line 116, in findCourse
    InPlanCourseInfo = json.loads(InPlanCourseInfo)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AppData\Local\anaconda3\Lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AppData\Local\anaconda3\Lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AppData\Local\anaconda3\Lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

然后两个json里面都是一些html数据:

<!DOCTYPE html><html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="renderer" content="webkit"><meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-Control" content="no-cache"><meta http-equiv="Expires" content="0"><meta http-equiv="Cache" content="no-cache"><title>研究生选课</title></head><body><div id="index_main_container" class="main" style="display:none"><header class="cv-page-header cv-absolute cv-clearfix-child"><div id="logoDiv" style="float:left"></div><nav><a style="display:none;color:#fff" id="switchLang" href="./index_en.html">English</a> <span style="display:none" id="logout">退出</span></nav></header><article class="cv-banner"><div class="cv-banner-bg"><div></div></div><section id="cv-xklc" class="cv-clearfix-child cvNoStartFlag"><div class="cv-no-start cv-clearfix-child" id="noStartDiv" style="display:none"><div id="xkwks_img1" style="width:316px;height:360px;float:left"></div><div class="cv-content"><div id="xkwks_img2"></div><div><div class="cv-first" style="margin-bottom:8px">同学:目前选课还未开始哦</div><div class="cv-last">请耐心等待校方通知~</div></div><div id="xkwks_img3"></div></div></div><div class="cv-stage-cont cv-pull-left"><nav id="cvStageAxis" class="cv-stage-axis"><div id="cvStageAxis_sjz" class="cv-block" style="display:none"><div class="cv-row"><div class="cv-left"></div><div class="cv-cycle"></div><div class="cv-right" id="sjz_start"></div></div><div class="cv-row"><div class="cv-left" style="margin-top:20px" id="sjz_name"></div><div class="cv-line" style="height:260px;margin-top:-14px"></div><div class="cv-right"></div></div><div class="cv-row"><div class="cv-left"></div><div class="cv-cycle"></div><div class="cv-right" id="sjz_end"></div></div><div class="cv-row"><div class="cv-left"></div><div class="cv-line-dotted"></div><div class="cv-right"></div></div></div></nav></div><div class="cv-countDown"><h2><span id="cvStageName" class="cvStageNamesf"></span> <button class="cv-btn cv-tag" type="button" id="stateMsg"></button></h2><div class="cv-mb-38"><div class="cv-countDown-start-text" id="timeMsg"></div><div id="cvFlipClock" style="clear:both"></div></div><div style="margin-bottom:24px"><table><tr><td style="font-size:14px;width:80px">选课模式</td><td><div id="xkmsDiv" class="cv-xkms" style="color:#f7c309"></div></td></tr></table></div><div><table><tr><td style="font-size:14px;width:80px">选课策略</td><td><div id="xkclDiv" class="cv-xkms"></div></td></tr></table></div></div><div class="cv-login" id="loginDiv" style="display:none"><h3>登录</h3><h5></h5><div id="loginNameDiv"><input role="login" type="text" id="loginName" placeholder="用户名(学号)"></div><div id="loginPwdDiv"><input role="login" type="password" id="loginPwd" placeholder="密码"></div><div class="cv-verification-code" id="verifyCodeDiv"><input role="login" type="text" id="verifyCode" placeholder="验证码"> <img id="vcodeImg" src=""></div><button class="cv-btn cv-btn-error" type="button" id="errorMsg" style="display:none">请填写用户名</button> <button class="cv-btn" type="button" id="studentLoginBtn">登 录</button></div><div class="cv-user" id="stundentinfoDiv" style="display:none"><div id="user_loadingDiv" style="display:none">正在加载,请稍候...</div><div id="user_contentDiv" user_loadingdiv><div class="cv-clearfix-child"><div class="cv-user-info-img" id="cv-user-info-img"></div><div class="cv-user-info-option"><h5 class="cv-mb-8">欢迎你&nbsp;<span id="user_name_span"></span></h5><div class="cv-mb-4 ellipsis" id="user_yx_span"></div><div id="user_nj_span"></div></div></div><div id="cvCreditChart" class="cv-credit-chart" style="width:140px;height:140px;margin-top:16px"></div><div id="cvCreditInfo" class="cv-credit-info cv-clearfix-child cv-mb-8"></div><div id="user_btnDiv" class="cv-user-my-plan" style="padding-top:8px;text-align:center"></div><div class="cv-user-my-plan" style="padding-top:16px;text-align:center"><a href="javascript:void(0);" id="gotoMyCourseTable" style="font-size:14px">查看我的课表</a></div></div></div></section></article><article class="cv-modules cv-clearfix-child"><section class="cv-pull-left cv-service-manual"><header><h3>操作手册(点击下图查看)</h3></header><div id="czsc_div"></div></section><section class="cv-pull-right"><header class="cv-mb-38"><h3>通知公告</h3></header><div id="cvNotificationList" class="cv-notification-list"><div style="color:#a9abad;font-size:12px">暂无数据</div></div></section><section class="cv-pull-left"><header class="cv-mb-38"><h3>常见问题</h3></header><div id="cvProblemList" class="cv-problem-list"><div style="color:#a9abad;font-size:12px">暂无数据</div></div></section><section class="cv-pull-right"><header class="cv-mb-56"><h3>咨询方式</h3></header><div class="cv-consulting"><div id="zxfs_bg" class="zxfs_bg"></div><h3></h3><div class="cv-consulting-phone"><div class="cv-mb-4" id="zxfs_sj"></div><div id="zxfs_dh"></div></div><div class="cv-consulting-other"><div class="cv-mb-4" id="zxfs_email"></div><div id="zxfs_qq"></div></div></div></section></article><footer class="cv-page-footer"><div id="ecDiv"></div><div id="cDiv"></div><div class="cv-mb-38 cv-caption-text" id="authorDiv"></div><div id="cv_copyright" class="cv-copyright"></div></footer></div><script type="text/javascript">var path_ggf=window.location.href,end_ggf=path_ggf.indexOf("/sys/"),context_path=path_ggf.substring(0,end_ggf),BaseUrl=context_path,length=BaseUrl.length;"/"==BaseUrl.indexOf(length-1,length)&&(BaseUrl=BaseUrl.substring(0,length-1));var commonUtil={loadJsCss:function(t,e,n){var o;"js"==e?((o=document.createElement("script")).setAttribute("type","text/javascript"),o.setAttribute("src",t)):"css"==e&&((o=document.createElement("link")).setAttribute("rel","stylesheet"),o.setAttribute("type","text/css"),o.setAttribute("href",t)),o&&(o.addEventListener?o.addEventListener("load",function(){"function"==typeof n&&n()},!1):o.attachEvent&&o.attachEvent("onreadystatechange",function(){"loaded"==window.event.srcElement.readyState&&"function"==typeof n&&n()}),document.getElementsByTagName("head")[0].appendChild(o))},ajax:function(t,e,n){commonUtil.simpleAjax({url:t.url,dataType:t.dataType,data:e,type:t.type,success:function(t){"function"==typeof n&&n(t)},error:function(t){}})},get:function(t,e,n){commonUtil.ajax({url:t,dataType:"json",type:"get"},e,n)},post:function(t,e,n){commonUtil.ajax({url:t,dataType:"json",type:"post"},e,n)},getRootPath:function(){var t=window.document.location.href,e=window.document.location.pathname,n=t.indexOf(e);return t.substring(0,n)+e.substring(0,e.substr(1).indexOf("/")+1)},simpleAjax:function(t){if(t.data=t.data||"",t.type=t.type||"get",!t.url)throw new Error("未指定连接");var e;t.async=t.async||!0,(e=window.VBArray?new ActiveXObject("Msxml2.XMLHTTP"):new XMLHttpRequest).open(t.type,t.url,t.async),e.onreadystatechange=function(){if(200!=e.status)throw new Error("请求失败,状态码:"+e.status);4==e.readyState&&t.success&&t.success(e.responseText)},"get"==t.type?e.send():(e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.send(t.data))},isBlank:function(t){return null==t||""===t},strOf:function(t){return null!=t&&null!=t&&""!==t?t+"":""},gotoDzPage:function(t,e){if(window.WIS_PUBLIC_INFO){var n="",o="course"===t?window.WIS_PUBLIC_INFO.coursePage:window.WIS_PUBLIC_INFO.indexPage;n=commonUtil.isBlank(o)?e+t+".html":e+o+".html",location.href=n}},checkAndGoDzPage:function(t,e){if(!commonUtil.isBlank(t)){var n=location.href.split("#")[0].split("/"),o=n[n.length-1].replace(".html","");-1===o.indexOf("en")&&t!==o&&(location.href=e+t+".html")}},getProjectName:function(){var t=window.document.location.href,e=window.document.location.pathname,n=t.indexOf(e);t.substring(0,n);return e.substring(0,e.substr(1).indexOf("/")+1)+"/"}},cookieUtil={set:function(t,e){var n=new Date;n.setTime(n.getTime()+2592e6),document.cookie=t+"="+escape(e)+";expires="+n.toGMTString()+";path="+commonUtil.getProjectName()},get:function(t){var e,n=new RegExp("(^| )"+t+"=([^;]*)(;|$)");return(e=document.cookie.match(n))?unescape(e[2]):null}};cookieUtil.set("EMAP_LANG","zh"),commonUtil.get(commonUtil.getRootPath()+"/sys/xsxkappbit/xsxkHome/loadPublicInfo_index.do",{},function(t){window.WIS_PUBLIC_INFO=JSON.parse(t),window.xkCache={publicInfo:window.WIS_PUBLIC_INFO},window.loginUserId=window.WIS_PUBLIC_INFO.loginUserId,window.appLogoutPath=window.WIS_PUBLIC_INFO.appLogoutPath,window.gotoWdjhPath=window.WIS_PUBLIC_INFO.gotoWdjhPath,window.WIS_PUBLIC_INFO.lcxxMap=window.WIS_PUBLIC_INFO.lcxx,commonUtil.loadJsCss(WIS_PUBLIC_INFO.resUrl+"/xsxkapp/indexjsp.min.css?v="+window.WIS_PUBLIC_INFO.system_boot_time,"css",function(){document.getElementById("index_main_container").style.display="block"});var e=commonUtil.isBlank(window.WIS_PUBLIC_INFO.stdInfoContentDefine)?"":"_"+window.WIS_PUBLIC_INFO.stdInfoContentDefine;commonUtil.loadJsCss(BaseUrl+"/sys/xsxkappbit/public/indexStdInfoContent"+e+".js?v="+window.WIS_PUBLIC_INFO.system_boot_time,"js"),commonUtil.loadJsCss(WIS_PUBLIC_INFO.resUrl+"/xsxkapp/indexjsp.js?v="+window.WIS_PUBLIC_INFO.system_boot_time,"js")})</script></body></html>
UkiTenzai commented 2 weeks ago

我使用的是xk_token这个cookie

Idlerz7 commented 2 weeks ago

我使用的是xk_token这个cookie

解决了吗哥

UkiTenzai commented 1 week ago

我使用的是xk_token这个cookie

解决了吗哥

还是不行哦 放弃了 叫老师加课算了

Jump-Wang-111 commented 6 days ago

看起来像cookie不对,抓课程信息的时候没有抓到,返回的数据是登录界面,是从f12里找的cookie吗? image

UkiTenzai commented 6 days ago

看起来像cookie不对,抓课程信息的时候没有抓到,返回的数据是登录界面,是从f12里找的cookie吗? image

image 我在这里找到的cookie

UkiTenzai commented 6 days ago

image 这里的cookie行不

Jump-Wang-111 commented 6 days ago

image 这里的cookie行不

这个可以,记得粘全,刚修了bug,现在请求不到课程应该会直接退出了

UkiTenzai commented 6 days ago

image 这里的cookie行不

这个可以,记得粘全,刚修了bug,现在请求不到课程应该会直接退出了

还是不行 一样是返回登陆界面 请问粘贴时是要粘贴成这样子吗?

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36',
    'Cookie': 'EMAP_LANG=zh; _WEU=AVg4xbbZVWSumeytlL656CHlXrWsP6Bctn3WdFGwUtm_Omp71LHiRG6uXXXXXXXXXwNBAIAT0O3f7rnPAAiOyep83WJv8S; JSESSIONID=5AE7997E1EEAAAAAAA9E4B9B1F27595A; route=ca1d7f4b7ee3666666b90886138f378d1; XK_TOKEN=5f322256-2589-4295-b13a-364888888'  # add your cookie here
}
UkiTenzai commented 6 days ago

image 这里的cookie行不

这个可以,记得粘全,刚修了bug,现在请求不到课程应该会直接退出了

还是不行 一样是返回登陆界面 请问粘贴时是要粘贴成这样子吗?

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36',
    'Cookie': 'EMAP_LANG=zh; _WEU=AVg4xbbZVWSumeytlL656CHlXrWsP6Bctn3WdFGwUtm_Omp71LHiRG6uXXXXXXXXXwNBAIAT0O3f7rnPAAiOyep83WJv8S; JSESSIONID=5AE7997E1EEAAAAAAA9E4B9B1F27595A; route=ca1d7f4b7ee3666666b90886138f378d1; XK_TOKEN=5f322256-2589-4295-b13a-364888888'  # add your cookie here
}
UkiTenzai commented 6 days ago

其实我昨天弄了一个自动刷新,刷新情况有变化就扬声器发出声音提醒我选课的js,放到浏览器控制台里面运行。一开始我是用平板亮屏挂着,但是担心对屏幕和电池有损伤,打算换个方案。请问大佬能指点一下吗?