青书学堂 看视频 耍课时

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

省了特别多的时间

相关推荐

  1. QT的模型&视图框架--笔记

    2024-06-14 07:42:03       18 阅读
  2. 学习软件测试建议些什么

    2024-06-14 07:42:03       30 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-06-14 07:42:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-14 07:42:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-14 07:42:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-14 07:42:03       18 阅读

热门阅读

  1. TCP是什么、UDP是什么,它们有什么区别

    2024-06-14 07:42:03       6 阅读
  2. WHAT - React 学习系列(一)

    2024-06-14 07:42:03       9 阅读
  3. .NET C# 实现国密算法加解密

    2024-06-14 07:42:03       3 阅读
  4. VB.net与C# 调用InitializeComponent的区别

    2024-06-14 07:42:03       6 阅读
  5. HarmonyOS(35) @State使用注意事项

    2024-06-14 07:42:03       5 阅读
  6. php学习笔记

    2024-06-14 07:42:03       6 阅读
  7. Android基础-应用的启动流程

    2024-06-14 07:42:03       6 阅读
  8. 19.2 HTTP客户端-定制HTTP请求、调试HTTP、响应超时

    2024-06-14 07:42:03       6 阅读
  9. Hadoop 3.X HA集群部署

    2024-06-14 07:42:03       4 阅读