青书学堂 看视频 耍课时

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

省了特别多的时间

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值