本帖最后由 南岸 于 2020-9-20 22:15 编辑
一个一个评价容易累死,所以今天就写了这个小工具
截图:
QQ截图20200920221532.png (337.17 KB, 下载次数: 0)
2020-9-20 22:15 上传
代码:
# -*- coding: utf-8 -*-
"""
home.php?mod=space&uid=238618 : 2020/9/20 11:32
@Auth : Ne-21
home.php?mod=space&uid=1416830 : 德育评测批处理
home.php?mod=space&uid=267492 :Hebust_dy.py
@IDE :PyCharm
@Motto:Another me.
"""
import requests
import time
import base64
import re
import html
class HebustDy(object):
def __init__(self):
self.stuNum = ''
self.pwd = ''
self.s = requests.Session()
self.header = {
'User-Agent': 'Mozilla / 5.0(Windows NT 10.0;WOW64) AppleWebKit / 537.36(KHTML, like Gecko) Chrome / 84.0.4147.105 Safari / 537.36'
}
def get_13_timestamp(self):
timestamp1 = time.time()
return int(round(timestamp1) * 1000)
def get_vcode(self):
imgurl = 'http://202.206.64.85/morality/verifyCode?d='+str(self.get_13_timestamp())
web = self.s.get(imgurl, headers=self.header)
img = base64.b64encode(web.content)
imgdata = re.findall("b'(.*?)'", str(img))[0]
img_data = base64.b64decode(imgdata)
with open("./img.png", "wb") as fb:
fb.write(img_data)
vcode = input("请输入验证码:")
return vcode
def login(self):
loginurl = 'http://202.206.64.85/morality/ajaxLogin'
data = {
'stuNum' : self.stuNum,
'pwd' : self.pwd,
'vcode' : self.get_vcode()
}
res = self.s.post(loginurl, headers=self.header, data=data)
logindata = (res.json()).get('data')
if logindata == True:
print("login success!")
pass
else:
print('login failure.')
self.stuNum = input("请输入账号:")
self.pwd = input('请输入密码:')
return self.login()
def get_student_list(self):
listurl = 'http://202.206.64.85/morality/index'
res = self.s.get(listurl, headers=self.header)
# print(res.text)
match = re.compile('
')eidlist = re.findall(match, res.text)
return eidlist
def main(self):
self.login()
for eid in self.get_student_list():
infourl = 'http://202.206.64.85/morality/evaluate?yid=2&id='+str(eid)
res = self.s.get(infourl, headers=self.header)
stuname = html.unescape(re.findall('', res.text)[0])
ename = html.unescape(re.findall('', res.text)[0])
data = {
'evaluate.id': str(eid),
'evaluate.yid': 2,
'evaluate.stuname': stuname,
'evaluate.stuNum': (re.findall('', res.text)[0]),
'evaluate.stuId': (re.findall('', res.text)[0]),
'evaluate.status': 0,
'evaluate.estuId': (re.findall('', res.text)[0]),
'evaluate.ename': ename,
'evaluate.estuNum': (re.findall('', res.text)[0]),
'evaluate.createTime': "",
'yid': "2",
'evaluate.politics': '1',
'evaluate.study': '1',
'evaluate.moral': '1',
'evaluate.labor': '1',
'evaluate.legal': '1',
'evaluate.practice': '1'
}
posturl = 'http://202.206.64.85/morality/save?timestamp='+str(self.get_13_timestamp())
self.s.post(posturl, headers=self.header, data=data)
print('对象-->'+str(stuname)+',ID-->'+str(eid)+'---->完成评价!')
time.sleep(2)
print('已全部完成!')
if __name__ == '__main__':
run = HebustDy()
run.main()