diff --git a/coc.py b/coc.py index 2a79d13..22ed3f4 100644 --- a/coc.py +++ b/coc.py @@ -1,5 +1,5 @@ # 引入文件夹中的文件 -from flask_cors import CORS +from flask_cors import CORS #跨域访问 import sys sys.path.append('./lib') from allFunction import manageLogin, managePhoto, manageAdd, manageDel, manageGet, manageDetail, manageComment @@ -7,7 +7,9 @@ from allFunction import manageLogin, managePhoto, manageAdd, manageDel, manageGe from flask import Flask, request, session app = Flask(__name__) -CORS(app, resources=r'/*') # 注册CORS, "/*" 允许访问所有api + +#取消跨域访问限制,方便本地测试 +#CORS(app, resources=r'/*') # 注册CORS, "/*" 允许访问所有api # 登录接口,前端提供cid和pwd,包装在data里边然后md5校验也就是data:{cid,pwd,sign} @app.route('/api/login',methods=['POST']) diff --git a/lib/__pycache__/db.cpython-37.pyc b/lib/__pycache__/db.cpython-37.pyc new file mode 100644 index 0000000..1f84508 Binary files /dev/null and b/lib/__pycache__/db.cpython-37.pyc differ diff --git a/lib/__pycache__/photoUpload.cpython-37.pyc b/lib/__pycache__/photoUpload.cpython-37.pyc new file mode 100644 index 0000000..6b5388c Binary files /dev/null and b/lib/__pycache__/photoUpload.cpython-37.pyc differ diff --git a/lib/crawler.py b/lib/crawler.py index fc7000a..539cb3d 100644 --- a/lib/crawler.py +++ b/lib/crawler.py @@ -168,6 +168,12 @@ def getGrade(Ip, S): def getSchedule(Ip, S): headers = {'Content-Type': 'application/json'} + r = S.post( + url='http://'+Ip[0]+'-'+Ip[1]+'-'+Ip[2]+'-'+Ip[3]+'-8080-p.webvpn.cust.edu.cn:8118/api/ClientStudent/Home/StudentHomeApi/GetHomeCurWeekTime?sf_request_type=ajax', + data=json.dumps({"param":"JTdCJTdE","__permission":{"MenuID":"F71C97D5-D3E2-4FDA-9209-D7FA8626390E","Operation":0},"__log":{"MenuID":"F71C97D5-D3E2-4FDA-9209-D7FA8626390E","Logtype":6,"Context":"查询"}}), + headers=headers + ) + CurWeek = json.loads(r.content.decode('utf-8'))['data']['CurWeek'] r = S.post( url='http://'+Ip[0]+'-'+Ip[1]+'-'+Ip[2]+'-'+Ip[3]+'-8080-p.webvpn.cust.edu.cn:8118/api/ClientStudent/Home/StudentHomeApi/QueryStudentScheduleData?sf_request_type=ajax', data=json.dumps({"param":"JTdCJTdE","__permission":{"MenuID":"F71C97D5-D3E2-4FDA-9209-D7FA8626390E","Operation":0},"__log":{"MenuID":"F71C97D5-D3E2-4FDA-9209-D7FA8626390E","Logtype":6,"Context":"查询"}}), @@ -179,12 +185,15 @@ def getSchedule(Ip, S): time = ['AM__TimePieces','PM__TimePieces','EV__TimePieces'] data = data['data']['AdjustDays'] days_per_week = [0] * 23 - lesson = [[0] * 7 for _ in range(6)] + lesson = [[0] * 6 for _ in range(7)] + lesson_set = {} + color_set = [0] * 9 + color_used = 9 for i in range(7): for j in range(3): for k in range(2): if( data[i][time[j]][k]['Dtos'] ): - lesson[j*2+k][i] = [] + lesson[i][j*2+k] = [] for l in data[i][time[j]][k]['Dtos']: temp_lesson = {} Time = [0] * 23 @@ -194,6 +203,16 @@ def getSchedule(Ip, S): temp_lesson[m['Key']] += ','+m['Name'] else: temp_lesson[m['Key']] = m['Name'] + if lesson_set.get(l['Content'][0]['Name']): + temp_lesson['color'] = lesson_set[l['Content'][0]['Name']] + else: + color = random.randint(0, 8) + while color_set[color] and color_used: + color = random.randint(0, 8) + temp_lesson['color'] = color + lesson_set[l['Content'][0]['Name']] = color + color_used -= 1 + color_set[color] = 1 temp_Time = temp_lesson['Time'] if '单周' in temp_Time: mod = 'single' @@ -223,17 +242,6 @@ def getSchedule(Ip, S): Time[int(n[0])] = 1 index += 1 temp_lesson['Time_split'] = Time - lesson[j*2+k][i].append(temp_lesson) - data_cache = {'lesson':lesson,'days_per_week':days_per_week} - return {'errcode': 200, 'errmsg': 'ok', 'data': data_cache} - -def getCurrentTime(Ip, S): - headers = {'Content-Type': 'application/json'} - r = S.post( - url='http://192-168-223-71-8080-p.webvpn.cust.edu.cn:8118/api/ClientStudent/Home/StudentHomeApi/GetHomeCurWeekTime?sf_request_type=ajax', - data=json.dumps({"param":"JTdCJTdE","__permission":{"MenuID":"F71C97D5-D3E2-4FDA-9209-D7FA8626390E","Operation":0},"__log":{"MenuID":"F71C97D5-D3E2-4FDA-9209-D7FA8626390E","Logtype":6,"Context":"查询"}}), - headers=headers - ) - data = json.loads(r.content.decode('utf-8')) - data_cache = data['data'].pop('DateList') - return {'errcode': 200, 'errmsg': 'ok', 'data': data_cache} + lesson[i][j*2+k].append(temp_lesson) + data_cache = {'lesson':lesson,'days_per_week':days_per_week,'cur_week':CurWeek} + return {'errcode': 200, 'errmsg': 'ok', 'data': data_cache} \ No newline at end of file