|
本代码仅供娱乐交流使用,切勿进行商用和违法用途
import requests
import json
import time
def Learn(courseName):
headers['Referer'] = 'https://zjy2.icve.com.cn/student/studio/studio.html'
responseLearn = requests.post('https://zjy2.icve.com.cn/api/student/learning/getLearnningCourseList',headers=headers)
jsonLearn = json.loads(responseLearn.content.decode('utf-8'))
for course in jsonLearn['courseList']:
if(course['courseName'] == courseName):
courseOpenId = course['courseOpenId']
openClassId = course['openClassId']
return courseOpenId,openClassId
def Process(courseOpenId,openClassId):
headers['Referer'] = 'https://zjy2.icve.com.cn/study/process/process.html?courseOpenId='+courseOpenId+'&openClassId='+openClassId
arrayProcess = []
data = {
'courseOpenId': courseOpenId,
'openClassId': openClassId
}
responseProcess = requests.post('https://zjy2.icve.com.cn/api/study/process/getProcessList',headers=headers,data=data)
jsonProcess = json.loads(responseProcess.text)
for moduList in jsonProcess['progress']['moduleList']:
if(moduList['percent']!=100):
arrayProcess.append({'moduleId':moduList['id']})
else:
print(moduList['name'] + " ····· 100%")
return arrayProcess
def ModuleId(moduleId,courseOpenId):
headers['Referer'] = 'https://zjy2.icve.com.cn/study/process/process.html?courseOpenId='+courseOpenId+'&openClassId='+openClassId
arrayModule = []
data = {
'courseOpenId': courseOpenId,
'moduleId': moduleId
}
responseModule = requests.post('https://zjy2.icve.com.cn/api/study/process/getTopicByModuleId', headers=headers, data=data)
jsonModule = json.loads(responseModule.text)
for moduList in jsonModule['topicList']:
arrayModule.append({'topicId':moduList['id']})
return arrayModule
def Topic(courseOpenId,openClassId,topicId):
headers['Referer'] = 'https://zjy2.icve.com.cn/study/process/process.html?courseOpenId='+courseOpenId+'&openClassId='+openClassId
arrayTopic = []
data = {
'courseOpenId': courseOpenId,
'openClassId': openClassId,
'topicId': topicId
}
responseTopic = requests.post('https://zjy2.icve.com.cn/api/study/process/getCellByTopicId', headers=headers,data=data)
jsonTopic = json.loads(responseTopic.text)
for cellList in jsonTopic['cellList']:
if(cellList['stuCellPercent']!=100):
arrayTopic.append({'cellId':cellList['Id'],'categoryName':cellList['categoryName']})
else:
print(cellList['cellName'] + "-" + cellList['categoryName'] + " ····· 100%")
return arrayTopic
def View(courseOpenId,openClassId,cellId,moduleId):
headers['Referer'] = 'https://zjy2.icve.com.cn/common/directory/directory.html?courseOpenId='+courseOpenId+'&openClassId='+openClassId+'&cellId='+cellId+'&flag=s&moduleId='+moduleId
data = {
'courseOpenId': courseOpenId,
'openClassId': openClassId,
'cellId': cellId,
'flag': 's',
'moduleId': moduleId
}
responseView = requests.post('https://zjy2.icve.com.cn/api/common/Directory/viewDirectory', headers=headers,data=data)
jsonView = json.loads(responseView.text)
if(jsonView['code']==-100):
dataChange = {
'courseOpenId': courseOpenId,
'openClassId': openClassId,
'cellId': cellId,
'moduleId': moduleId,
'cellName': jsonView['currCellName']
}
requests.post('https://zjy2.icve.com.cn/api/common/Directory/changeStuStudyProcessCellData', headers=headers, data=dataChange)
responseView = requests.post('https://zjy2.icve.com.cn/api/common/Directory/viewDirectory', headers=headers,
data=data)
jsonView = json.loads(responseView.text)
return jsonView['audioVideoLong'], jsonView['cellName'], jsonView['guIdToken'], jsonView['stuStudyNewlyTime'], \
jsonView['cellPercent'], jsonView['resUrl']
return jsonView['audioVideoLong'],jsonView['cellName'],jsonView['guIdToken'],jsonView['stuStudyNewlyTime'],jsonView['cellPercent'],jsonView['resUrl']
def CellLog(courseOpenId,openClassId,cellId,audioVideoLong,cellName,guIdToken,stuStudyNewlyTime,cellPercent,categoryName,resUrl):
headers['Referer'] = 'https://zjy2.icve.com.cn/common/directory/directory.html?courseOpenId='+courseOpenId+'&openClassId='+openClassId+'&cellId='+cellId+'&flag=s&moduleId='+moduleId
if(categoryName=='视频'):
studyTime = stuStudyNewlyTime
while True:
startTime = time.time()
if(cellPercent==100):
print(cellName + '-' + categoryName + " ····· 100%")
break
data = {
'courseOpenId': courseOpenId,
'openClassId': openClassId,
'cellId': cellId,
'cellLogId':'',
'picNum': '0',
'studyNewlyTime': str(round(studyTime,6)),
'studyNewlyPicNum': '0',
'token': guIdToken
}
time.sleep(10)
endTime = time.time()
addTime = endTime - startTime
studyTime += addTime
if (studyTime >= audioVideoLong):
studyTime = audioVideoLong
try:
responseCell = requests.post('https://zjy2.icve.com.cn/api/common/Directory/stuProcessCellLog', headers=headers, data=data ,timeout=10)
jsonCell = json.loads(responseCell.content.decode('utf-8'))
if (int(studyTime) == 0):
percent = 0
else:
percent = round(studyTime * 100 / audioVideoLong, 2)
if (jsonCell['code'] == 1):
print(cellName + '-' + categoryName + " ····· " + str(percent) + "%")
if (studyTime >= audioVideoLong):
break
except:
pass
elif(categoryName=='ppt'):
pages = json.loads(resUrl)['args']['page_count']
for page in range(1,pages+1):
if (cellPercent == 100):
print(cellName + '-' + categoryName + " ····· 100%")
break
data = {
'courseOpenId': courseOpenId,
'openClassId': openClassId,
'cellId': cellId,
'cellLogId': '',
'picNum': page,
'studyNewlyTime': '0',
'studyNewlyPicNum': page,
'token': guIdToken
}
responseCell = requests.post('https://zjy2.icve.com.cn/api/common/Directory/stuProcessCellLog', headers=headers,data=data)
jsonCell = json.loads(responseCell.text)
if (jsonCell['code'] == 1):
print(cellName + '-' + categoryName + " ····· " + str(round(page * 100 / pages,2)) + "%")
time.sleep(2)
elif (categoryName == 'swf'):
for page in range(1,5):
if (cellPercent == 100):
print(cellName + '-' + categoryName + " ····· 100%")
break
data = {
'courseOpenId': courseOpenId,
'openClassId': openClassId,
'cellId': cellId,
'cellLogId': '',
'picNum': '0',
'studyNewlyTime': '0',
'studyNewlyPicNum': '0',
'token': guIdToken
}
responseCell = requests.post('https://zjy2.icve.com.cn/api/common/Directory/stuProcessCellLog',
headers=headers, data=data)
jsonCell = json.loads(responseCell.text)
if (jsonCell['code'] == 1):
print(cellName + '-' + categoryName + " ····· 100%")
time.sleep(2)
if __name__ == '__main__':
Cookie = "" #放入你自己的cookie
courseName = "" #放入你想**视频的课程名字
headers = {
'Host': 'zjy2.icve.com.cn',
'Origin': 'https://zjy2.icve.com.cn',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36',
'Cookie': Cookie}
courseOpenId,openClassId = Learn(courseName)
processs = Process(courseOpenId,openClassId)
for process in processs:
moduleId = process['moduleId']
modules = ModuleId(moduleId,courseOpenId)
for module in modules:
topicId = module['topicId']
topics = Topic(courseOpenId,openClassId,topicId)
for topic in topics:
cellId=topic['cellId']
categoryName = topic['categoryName']
audioVideoLong,cellName,guIdToken,stuStudyNewlyTime,cellPercent,resUrl=View(courseOpenId,openClassId,cellId,moduleId)
CellLog(courseOpenId,openClassId,cellId,audioVideoLong,cellName,guIdToken,stuStudyNewlyTime,cellPercent,categoryName,resUrl)
|
|