青书学堂 看视频 耍课时

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小时过后 把这一个课程的所有 章节就看完了

省了特别多的时间

相关推荐
芯橦35 分钟前
【瑞昱RTL8763E】音频
单片机·嵌入式硬件·mcu·物联网·音视频·visual studio code·智能手表
ac-er88881 小时前
PHP“===”的意义
开发语言·php
wxin_VXbishe1 小时前
springboot合肥师范学院实习实训管理系统-计算机毕业设计源码31290
java·spring boot·python·spring·servlet·django·php
小小不董1 小时前
《Linux从小白到高手》理论篇:深入理解Linux的网络管理
linux·运维·服务器·数据库·php·dba
豆豆2 小时前
为什么用PageAdmin CMS建设网站?
服务器·开发语言·前端·php·软件构建
9527华安2 小时前
FPGA实现PCIE视频采集转HDMI输出,基于XDMA中断架构,提供3套工程源码和技术支持
fpga开发·音视频·pcie·xdma·ov5640·hdmi
NiNg_1_2343 小时前
ThinkPHP5基础入门
php
2401_857610034 小时前
SpringBoot实现:校园资料分享平台开发指南
服务器·spring boot·php
Q_w77424 小时前
一个真实可用的登录界面!
javascript·mysql·php·html5·网站登录
一丝晨光5 小时前
Java、PHP、ASP、JSP、Kotlin、.NET、Go
java·kotlin·go·php·.net·jsp·asp