本文主要是介绍青书学堂 看视频 耍课时,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1. 获取课程节点id
( /nynzy/Student/Course/GetStudyRecordAndScore ) 接口地址
2. 把所有的nodeId 保存下来 保存到 old.txt
格式 课程id 与 nodeId 用 | 隔开
3. 然后创建 test.php
注意把 cookie 换成自己的
<?php$oldFilename = './old.txt';
$newFilename = './new.txt';$oldData = file_get_contents($oldFilename);
$oldData = explode("\r\n", $oldData);
$newData = [];
foreach ($oldData as $key => $value) {if (empty($value)) {continue;}$tmp = explode('|', $value);$courseId = $tmp[0];$contentId = $tmp[1];echo PHP_EOL. $courseId . ' ' . $contentId;$beginId = begin($courseId, $contentId);$newData[] = [$courseId, $contentId, $beginId];$str = $courseId . '|' . $contentId . '|' . $beginId . PHP_EOL;file_put_contents($newFilename, $str, FILE_APPEND);refresh($beginId,$courseId, $contentId);}
$i = 360;
while ($i > 0) {$i --;echo '还剩 ' . $i . ' 次刷新' . PHP_EOL;foreach ($newData as $key => $value) {refresh($value[2],$value[0], $value[1]);}sleep(10);
}
echo '结束';function begin($courseId, $contentId)
{$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL => 'https://degree.qingshuxuetang.com/nynzy/Student/Course/UploadStudyRecordBegin?_t=' . (time() * 1000),CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => '',CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 0,CURLOPT_FOLLOWLOCATION => true,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => 'POST',CURLOPT_POSTFIELDS => '{"classId": "34","courseId": "' . $courseId . '","contentId": "' . $contentId . '","contentType": 11,"periodId": "21","position": 0,"detectId": null}',CURLOPT_HTTPHEADER => array('Accept: application/json','Accept-Language: zh-CN,zh;q=0.9','Connection: keep-alive','Device-Trace-Id-QS: 027d06da-4bd6-4817-8c7e-28fd518162dd','Origin: https://degree.qingshuxuetang.com',"Referer: https://degree.qingshuxuetang.com/nynzy/Student/Course/CourseShow?teachPlanId=34&periodId=21&courseId=$courseId&nodeId=$contentId",'Cookie: AccessToken=换成自己的; __environment=production','User-Agent: Apifox/1.0.0 (https://apifox.com)','Content-Type: application/json','Host: degree.qingshuxuetang.com'),));$response = curl_exec($curl);echo 'begin 请求结果:' . $response . PHP_EOL;curl_close($curl);$response = json_decode($response, true);if ($response['message'] == '成功') {return $response['data'];} else {dd($response);}
}
function dd($data)
{print_r($data);die();
}function refresh($id,$courseId, $contentId)
{$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL => 'https://degree.qingshuxuetang.com/nynzy/Student/Course/UploadStudyRecordContinue?_t=' . (time() * 1000),CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => '',CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 0,CURLOPT_FOLLOWLOCATION => true,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => 'POST',CURLOPT_POSTFIELDS => array('recordId' => $id, 'end' => 'true', 'position' => '3000', 'timeOutConfirm' => 'false'),CURLOPT_HTTPHEADER => array('Accept: application/json','Accept-Language: zh-CN,zh;q=0.9','Connection: keep-alive','Cookie: AccessToken=换成自己的; __environment=production','Device-Trace-Id-QS: 027d06da-4bd6-4817-8c7e-28fd518162dd','Origin: https://degree.qingshuxuetang.com',"Referer: https://degree.qingshuxuetang.com/nynzy/Student/Course/CourseShow?teachPlanId=34&periodId=21&courseId=$courseId&nodeId=$contentId",'Sec-Fetch-Dest: empty','Sec-Fetch-Mode: cors','Sec-Fetch-Site: same-origin','User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0','X-Requested-With: XMLHttpRequest','sec-ch-ua: "Chromium";v="122", "Not(A:Brand";v="24", "Microsoft Edge";v="122"','sec-ch-ua-mobile: ?0','sec-ch-ua-platform: "Windows"'),));$response = curl_exec($curl);// dd(curl_errno($curl));echo 'refresh 请求结果:' . $response . PHP_EOL;curl_close($curl);$response = json_decode($response, true);if ($response['message'] == '成功') {return true;} else {echo '响应错误';// dd($response);}
}
4. 运行 test.php
定时是1小时 1小时过后 把这一个课程的所有 章节就看完了
省了特别多的时间
这篇关于青书学堂 看视频 耍课时的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!