职教云刷今日课堂课前课后回复和课程评价,自我总结
本帖最后由 plutoldc 于 2020-6-20 17:01 编辑已经有大佬写出来过了,我觉得有点不完善,有的课堂会没有加上去,我又重新写了一下,按照课程刷,运行如图,
下面贴上代码,刚接触Python,有的地方可能会有一点不合理,希望大家指正
# 导入包
import requests
import json
# 定义全局变量
session = requests.Session()# 定义session
cookies = {}
myId, myNewToken, courseOpenId, openClassId = '', '', '', ''# 自己的id,课程id,班级id
todayTypeNames = ['课前安排', '课中', '课后安排']
isReply = True# 是否回复和查看课前课后安排
replyRequireContent = ['1', '', '1']# 课前 课后 安排的回复
replySelf = ['挺好的', '挺好的']# 课堂评价 自我总结
# 定义函数
# 格式化json数据
def formatJson(res):
return json.loads(res.text)
# 登陆
def login(userName, userPwd):# 登陆
global myId, cookies, myNewToken
url = "https://zjyapp.icve.com.cn/newmobileapi/mobilelogin/newlogin"
data = {
"appVersion": "2.8.23",
"clientId": "04fbaf3b874041b68db529f24b5aa86b",
"sourceType": 3,
"userName": userName,
"userPwd": userPwd
}
res = session.post(url, data=data)
userInfo = formatJson(res)
# print(userInfo)
if userInfo['code'] != 1:
print(userInfo['msg'])
else:
print("账户登陆成功!")
myId = userInfo['userId']
myNewToken = userInfo['newToken']
cookies = requests.utils.dict_from_cookiejar(res.cookies)
# 获取课程列表
def getCourseList():
global courseOpenId, openClassId
url = "https://zjy2.icve.com.cn/api/student/learning/getLearnningCourseList"
res = session.post(url)
info = formatJson(res)
if info['code'] == 1:
CourseList = info['courseList']
print("【课程】账号下共有" + str(len(CourseList)) + "门课程")
index = 0
for item in CourseList:
print(str(index) + ". " + item['courseName'])
index += 1
c_index = input("请输入课程序号:")
courseOpenId = CourseList['courseOpenId']
openClassId = CourseList['openClassId']
# 获取课程今日课堂列表
def getStuFaceTeachList():
url = "https://zjyapp.icve.com.cn/newmobileapi/faceteach/getStuFaceTeachList"
data = {
'courseOpenId': courseOpenId,
'openClassId': openClassId,
'stuId': myId,
'newToken': myNewToken
}
res = session.post(url, data=data, cookies=cookies)
info = json.loads(res.text)
if info['code'] == 1:
dataList = info['dataList']
print("课程下今日课堂列表获取成功!")
for item in dataList:
print("正在操作的今日课堂为:--------------->>>", item['Title'])
activityId = item['Id']
# 发表回复模块,由isReply决定是否运行
if isReply:
for i in :
faceTeachActivityInfo(activityId, i)
# 课堂评价 自我总结模块
# 发表课堂评价
info = evaluationSave(activityId)
if info['code'] == 1:
print("课堂评价--------------->>>" + "评价成功!", "评价内容为:" + replySelf)
else:
print("课堂评价--------------->>>" + info['msg'], "评价内容为:" + replySelf)
# 保存自我总结
info = selfratingSave(activityId)
print("自我总结--------------->>>" + info['msg'], "总结内容为:" + replySelf)
# 保存自我总结
def selfratingSave(activityId):
url = 'https://security.zjy2.icve.com.cn/api/study/faceTeachInfo/selfratingSave'
data = {
'activityId': activityId,
'courseOpenId': courseOpenId,
'openClassId': openClassId,
'stuContent': replySelf,
'star': 5
}
info = formatJson(session.post(url, data=data))
return info
# 发表课堂评价
def evaluationSave(activityId):
url = 'https://security.zjy2.icve.com.cn/api/study/faceTeachInfo/evaluationSave'
data = {
'activityId': activityId,
'courseOpenId': courseOpenId,
'openClassId': openClassId,
'stuContent': replySelf,
'star': 5
}
info = formatJson(session.post(url, data=data))
return info
# 查看今日课堂 课中 课前 课后 的内容
def faceTeachActivityInfo(activityId, typeNum):
url = 'https://security.zjy2.icve.com.cn/api/study/faceTeachInfo/faceTeachActivityInfo'
data = {
'type': typeNum,
'courseOpenId': courseOpenId,
'openClassId': openClassId,
'activityId': activityId
}
info = formatJson(session.post(url, data=data))
if info['requireInfo'] is not None:
requireId = info['requireInfo']['Id']
if not getFaceTeachRequireInfo(activityId, requireId, typeNum):
print(todayTypeNames + "--------------->>>", "您已经发表过回复!", )
else:
if replyRequire(activityId, requireId, typeNum) == 1:
print(todayTypeNames + "--------------->>>", "发表回复成功:", replyRequireContent)
else:
print(todayTypeNames + "--------------->>>", "发表回复失败!")
# 查看课前 课后 的安排 若已回复过,返回False 若没有 返回True
def getFaceTeachRequireInfo(activityId, requireId, typeNum):
url = 'https://security.zjy2.icve.com.cn/api/study/faceTeachInfo/getFaceTeachRequireInfo'
data = {
'courseOpenId': courseOpenId,
'openClassId': openClassId,
'activityId': activityId,
'requireId': requireId,
'type': typeNum,
'selectType': 2
}
info = formatJson(session.post(url, data=data))
if info['code'] == 1:
replyList = info['requireInfo']['replyList']
for item in replyList:
if item['CreatorId'] == myId:
return False
return True
# 课前课后安排-------->>发表回复
def replyRequire(activityId, requireId, typeNum):
url = 'https://security.zjy2.icve.com.cn/api/study/faceTeachInfo/replyRequire'
data = {
'courseOpenId': courseOpenId,
'openClassId': openClassId,
'activityId': activityId,
'requireId': requireId,
'content': replyRequireContent,
'type': typeNum,
'dataJson': [{}]
}
info = formatJson(session.post(url, data=data))
code = info['code']
return code
# 运行
if __name__ == '__main__':
login(input("输入账号:"), input("输入密码:"))
getCourseList()
getStuFaceTeachList()
觉得有用的话免费评分走一波呗:shutup: 大哥搞个成品出来撒, 大哥 ,求成品
个人taken一直验证的都不对 运行反馈这个
SyntaxError: multiple statements found while compiling a single statement
页:
[1]