• 青书学堂 看视频 耍课时


    1. 获取课程节点id

    ( /nynzy/Student/Course/GetStudyRecordAndScore ) 接口地址

    2. 把所有的nodeId 保存下来  保存到 old.txt

    格式  课程id 与 nodeId 用 | 隔开

    3. 然后创建 test.php

    注意把 cookie 换成自己的

    1. <?php
    2. $oldFilename = './old.txt';
    3. $newFilename = './new.txt';
    4. $oldData = file_get_contents($oldFilename);
    5. $oldData = explode("\r\n", $oldData);
    6. $newData = [];
    7. foreach ($oldData as $key => $value) {
    8. if (empty($value)) {
    9. continue;
    10. }
    11. $tmp = explode('|', $value);
    12. $courseId = $tmp[0];
    13. $contentId = $tmp[1];
    14. echo PHP_EOL. $courseId . ' ' . $contentId;
    15. $beginId = begin($courseId, $contentId);
    16. $newData[] = [$courseId, $contentId, $beginId];
    17. $str = $courseId . '|' . $contentId . '|' . $beginId . PHP_EOL;
    18. file_put_contents($newFilename, $str, FILE_APPEND);
    19. refresh($beginId,$courseId, $contentId);
    20. }
    21. $i = 360;
    22. while ($i > 0) {
    23. $i --;
    24. echo '还剩 ' . $i . ' 次刷新' . PHP_EOL;
    25. foreach ($newData as $key => $value) {
    26. refresh($value[2],$value[0], $value[1]);
    27. }
    28. sleep(10);
    29. }
    30. echo '结束';
    31. function begin($courseId, $contentId)
    32. {
    33. $curl = curl_init();
    34. curl_setopt_array($curl, array(
    35. CURLOPT_URL => 'https://degree.qingshuxuetang.com/nynzy/Student/Course/UploadStudyRecordBegin?_t=' . (time() * 1000),
    36. CURLOPT_RETURNTRANSFER => true,
    37. CURLOPT_ENCODING => '',
    38. CURLOPT_MAXREDIRS => 10,
    39. CURLOPT_TIMEOUT => 0,
    40. CURLOPT_FOLLOWLOCATION => true,
    41. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    42. CURLOPT_CUSTOMREQUEST => 'POST',
    43. CURLOPT_POSTFIELDS => '{
    44. "classId": "34",
    45. "courseId": "' . $courseId . '",
    46. "contentId": "' . $contentId . '",
    47. "contentType": 11,
    48. "periodId": "21",
    49. "position": 0,
    50. "detectId": null
    51. }',
    52. CURLOPT_HTTPHEADER => array(
    53. 'Accept: application/json',
    54. 'Accept-Language: zh-CN,zh;q=0.9',
    55. 'Connection: keep-alive',
    56. 'Device-Trace-Id-QS: 027d06da-4bd6-4817-8c7e-28fd518162dd',
    57. 'Origin: https://degree.qingshuxuetang.com',
    58. "Referer: https://degree.qingshuxuetang.com/nynzy/Student/Course/CourseShow?teachPlanId=34&periodId=21&courseId=$courseId&nodeId=$contentId",
    59. 'Cookie: AccessToken=换成自己的; __environment=production',
    60. 'User-Agent: Apifox/1.0.0 (https://apifox.com)',
    61. 'Content-Type: application/json',
    62. 'Host: degree.qingshuxuetang.com'
    63. ),
    64. ));
    65. $response = curl_exec($curl);
    66. echo 'begin 请求结果:' . $response . PHP_EOL;
    67. curl_close($curl);
    68. $response = json_decode($response, true);
    69. if ($response['message'] == '成功') {
    70. return $response['data'];
    71. } else {
    72. dd($response);
    73. }
    74. }
    75. function dd($data)
    76. {
    77. print_r($data);
    78. die();
    79. }
    80. function refresh($id,$courseId, $contentId)
    81. {
    82. $curl = curl_init();
    83. curl_setopt_array($curl, array(
    84. CURLOPT_URL => 'https://degree.qingshuxuetang.com/nynzy/Student/Course/UploadStudyRecordContinue?_t=' . (time() * 1000),
    85. CURLOPT_RETURNTRANSFER => true,
    86. CURLOPT_ENCODING => '',
    87. CURLOPT_MAXREDIRS => 10,
    88. CURLOPT_TIMEOUT => 0,
    89. CURLOPT_FOLLOWLOCATION => true,
    90. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    91. CURLOPT_CUSTOMREQUEST => 'POST',
    92. CURLOPT_POSTFIELDS => array('recordId' => $id, 'end' => 'true', 'position' => '3000', 'timeOutConfirm' => 'false'),
    93. CURLOPT_HTTPHEADER => array(
    94. 'Accept: application/json',
    95. 'Accept-Language: zh-CN,zh;q=0.9',
    96. 'Connection: keep-alive',
    97. 'Cookie: AccessToken=换成自己的; __environment=production',
    98. 'Device-Trace-Id-QS: 027d06da-4bd6-4817-8c7e-28fd518162dd',
    99. 'Origin: https://degree.qingshuxuetang.com',
    100. "Referer: https://degree.qingshuxuetang.com/nynzy/Student/Course/CourseShow?teachPlanId=34&periodId=21&courseId=$courseId&nodeId=$contentId",
    101. 'Sec-Fetch-Dest: empty',
    102. 'Sec-Fetch-Mode: cors',
    103. 'Sec-Fetch-Site: same-origin',
    104. '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',
    105. 'X-Requested-With: XMLHttpRequest',
    106. 'sec-ch-ua: "Chromium";v="122", "Not(A:Brand";v="24", "Microsoft Edge";v="122"',
    107. 'sec-ch-ua-mobile: ?0',
    108. 'sec-ch-ua-platform: "Windows"'
    109. ),
    110. ));
    111. $response = curl_exec($curl);
    112. // dd(curl_errno($curl));
    113. echo 'refresh 请求结果:' . $response . PHP_EOL;
    114. curl_close($curl);
    115. $response = json_decode($response, true);
    116. if ($response['message'] == '成功') {
    117. return true;
    118. } else {
    119. echo '响应错误';
    120. // dd($response);
    121. }
    122. }
    4. 运行  test.php 

    定时是1小时  1小时过后 把这一个课程的所有 章节就看完了

    省了特别多的时间

  • 相关阅读:
    Mysql压缩包安装过程细节说明
    程序员35岁之后不写程序了,该怎样职业规划?
    vivo 容器集群监控系统架构与实践
    如何快速下载mysql的不同版本并启动mysql服务?
    keycloak~RequiredActionProvider的使用
    SQL数据库性能优化
    EXPLAIN概述与字段剖析
    利用datafaker批量生成测试数据
    Scala
    java计算机毕业设计家教到家平台MyBatis+系统+LW文档+源码+调试部署
  • 原文地址:https://blog.csdn.net/qq_36999656/article/details/139661130