吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4780|回复: 4
收起左侧

[Python 转载] 职教云刷今日课堂课前课后回复和课程评价,自我总结

[复制链接]
plutoldc 发表于 2020-6-19 23:32
本帖最后由 plutoldc 于 2020-6-20 17:01 编辑

已经有大佬写出来过了,我觉得有点不完善,有的课堂会没有加上去,我又重新写了一下,按照课程刷,运行如图,

输入课程序号来选择刷哪门课

输入课程序号来选择刷哪门课

然后就开始刷了

然后就开始刷了

更改这个值来确定是否回复和查看老师的课前课后要求

更改这个值来确定是否回复和查看老师的课前课后要求

下面贴上代码,刚接触Python,有的地方可能会有一点不合理,希望大家指正
[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[int(c_index)]['courseOpenId']
        openClassId = CourseList[int(c_index)]['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 [1, 3]:
                    faceTeachActivityInfo(activityId, i)
            # 课堂评价 自我总结模块
            # 发表课堂评价
            info = evaluationSave(activityId)
            if info['code'] == 1:
                print("课堂评价--------------->>>" + "评价成功!", "评价内容为:" + replySelf[0])
            else:
                print("课堂评价--------------->>>" + info['msg'], "评价内容为:" + replySelf[0])
            # 保存自我总结
            info = selfratingSave(activityId)
            print("自我总结--------------->>>" + info['msg'], "总结内容为:" + replySelf[1])


# 保存自我总结
def selfratingSave(activityId):
    url = 'https://security.zjy2.icve.com.cn/api/study/faceTeachInfo/selfratingSave'
    data = {
        'activityId': activityId,
        'courseOpenId': courseOpenId,
        'openClassId': openClassId,
        'stuContent': replySelf[1],
        '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[0],
        '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[typeNum - 1] + "--------------->>>", "您已经发表过回复!", )
        else:
            if replyRequire(activityId, requireId, typeNum) == 1:
                print(todayTypeNames[typeNum - 1] + "--------------->>>", "发表回复成功:", replyRequireContent[typeNum - 1])
            else:
                print(todayTypeNames[typeNum - 1] + "--------------->>>", "发表回复失败!")


# 查看课前 课后 的安排 若已回复过,返回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[typeNum - 1],
        'type': typeNum,
        'dataJson': [{}]
    }
    info = formatJson(session.post(url, data=data))
    code = info['code']
    return code


# 运行
if __name__ == '__main__':
    login(input("输入账号:"), input("输入密码:"))
    getCourseList()
    getStuFaceTeachList()


觉得有用的话免费评分走一波呗

免费评分

参与人数 3吾爱币 +2 热心值 +3 收起 理由
wanghz + 1 我很赞同!
l906215579 + 1 + 1 热心回复!
hgwl666 + 1 + 1 热心回复!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

l906215579 发表于 2020-6-21 00:36
大哥搞个成品出来撒,
lluo 发表于 2020-6-24 21:45
lluo 发表于 2020-6-24 23:48
haimiandashu 发表于 2020-9-30 00:27
运行反馈这个
SyntaxError: multiple statements found while compiling a single statement
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-25 23:43

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表