diff --git a/__pycache__/coc.cpython-37.pyc b/__pycache__/coc.cpython-37.pyc new file mode 100644 index 0000000..a690063 Binary files /dev/null and b/__pycache__/coc.cpython-37.pyc differ diff --git a/lib/__pycache__/db.cpython-37.pyc b/lib/__pycache__/db.cpython-37.pyc new file mode 100644 index 0000000..4281b00 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/allFunction.py b/lib/allFunction.py index 7931d01..ec67b09 100644 --- a/lib/allFunction.py +++ b/lib/allFunction.py @@ -137,9 +137,12 @@ def connect(data): # 用户密码 pwd = data['pwd'] # 进行登录 + phone = '' + if data.get('phone'): + phone = data['phone'] try: # 这里教务没问题,账户没问题就是200,密码错了就是101 - res = connection(cid,pwd) + res = connection(cid,pwd,phone) return res except: # 这了就是教务挂了 diff --git a/lib/crawler.py b/lib/crawler.py index 6567fd4..302860f 100644 --- a/lib/crawler.py +++ b/lib/crawler.py @@ -5,7 +5,26 @@ import base64 from bs4 import BeautifulSoup import random -def connection(username,password): + +def addphonenumber(): + return ''' + +
+请输入手机号
+教务新要求,需要绑定手机
+如果不放心,可以登录教务查看
+谢谢
+ + + + + + +''' + + + +def connection(username,password,phone): s = requests.Session() # 获取统一身份系统的网页 r = s.get(url='http://mysso-cust-edu-cn-s.webvpn.cust.edu.cn:8118/cas/login?service=https%3A%2F%2Fwebvpn.cust.edu.cn%2Fauth%2Fcas_validate%3Fentry_id%3D1') @@ -20,6 +39,19 @@ def connection(username,password): 'geolocation':'' } r = s.post(url='http://mysso-cust-edu-cn-s.webvpn.cust.edu.cn:8118/cas/login?service=https%3A%2F%2Fwebvpn.cust.edu.cn%2Fauth%2Fcas_validate%3Fentry_id%3D1',data=formdata) + soup=BeautifulSoup(r.text,'html.parser') + flag = soup.find(name='title') + if(flag.text=="手机号设置"): + execution=soup.find_all(name='input')[1]['value'] + formdata = { + 'phone': phone, + 'execution': execution, + '_eventId': 'submit', + 'submit': '提交' + } + print(execution) + r = s.post(url="http://mysso-cust-edu-cn-s.webvpn.cust.edu.cn:8118/cas/login?service=https%3A%2F%2Fwebvpn.cust.edu.cn%2Fauth%2Fcas_validate%3Fentry_id%3D1",data=formdata) + print(r.text) r = s.get(url='http://portal-cust-edu-cn-s.webvpn.cust.edu.cn:8118/custp/index') soup=BeautifulSoup(r.text,'html.parser') try: @@ -36,6 +68,7 @@ def connection(username,password): data = json.loads(r.content.decode('utf-8')) student_name = data['data']['StudentDto']['XM'] student_id = data['data']['StudentDto']['XH'] + print(student_name) return {'errcode': 200, 'errmsg': 'ok', 'ip': ip, 's': s,'student_name':student_name,'student_id':student_id} def getGrade(Ip, S): @@ -238,4 +271,4 @@ def getCurrentTime(Ip, S): ) data = json.loads(r.content.decode('utf-8')) data_cache = data['data'].pop('DateList') - return {'errcode': 200, 'errmsg': 'ok', 'data': data_cache} + return {'errcode': 200, 'errmsg': 'ok', 'data': data_cache} \ No newline at end of file