|
本帖最后由 jiteloozz 于 2022-9-4 11:43 编辑
云课堂系列(3)出炉,欢迎测试学习,若有不足之处,感谢指正~~~
云课堂系列详见:
1.上海空中课堂PHP https://www.right.com.cn/forum/thread-8247811-1-1.html
2.北京空中课堂PHP https://www.right.com.cn/forum/thread-8248610-1-1.html
3.云课堂系列(3)---天津初高中精品课程.PHP https://www.right.com.cn/forum/thread-8252473-1-1.html
4.云课堂系列(4)---江苏高中名师优课.PHP https://www.right.com.cn/forum/thread-8252479-1-1.html
5.云课堂系列(5)---广州全年级共享课堂.PHP https://www.right.com.cn/forum/thread-8252487-1-1.html
代理测试:
第5课时 微型课5 解一元二次方程(4),http://mmitv.top/test/tjykt.php? ... 0&gid=9&sid=13&tag=初九第二学期
随机学习高一一节课程:http://mmitv.top/test/tjykt.php?id=&gid=10&sid=13
PHP完整代码及食用方法回复可见:
- <?php
- /***********************
- 随机学习高一第一学期一节课程:http://XXXXX/tjykt.php?id=&gid=10&sid=12
- 获取高一第二学期全部课程列表:http://XXXXX/tjykt.php?id=list&gid=10&sid=13
- 其他课程参数根据数组$gids和$sids的元素值自行修改即可。
- ***********************/
- $id = isset($_GET['id'])?$_GET['id']:'list';
- $gid = isset($_GET['gid'])?$_GET['gid']:'10';
- $sid = isset($_GET['sid'])?$_GET['sid']:'13';
- $sids=array(
- 12=>'第一学期',
- 13=>'第二学期',
- );
- $gids=array(
- 7=>'初七',//216211151,214699748
- 8=>'初八',//216211154,214699761
- 9=>'初九',//222659011,214699769
- 10=>'高一',//216211134,214713773
- 11=>'高二',//222635813,214713796
- 12=>'高三',//222659369,214713826
- );
- if(empty($gids[$gid])||$gid=='rand'){
- $gid=array_keys($gids)[array_rand(array_keys($gids),1)];
- }
- if(empty($sids[$sid])||$sid=='rand'){
- $sid=array_keys($sids)[array_rand(array_keys($sids),1)];
- }
- $header=array(
- 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8',
- 'Referer: http://mooc1.chaoxing.com/',
- "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36",
- );
- $headers=stream_context_create(['http'=>['header'=>$header]]);
- if($id=='list'||$id==''){
- $phase=3;
- if($gid<=9){
- $phase=2;
- }
- $url='http://tjedu.tjjy.com.cn/api/erqi/course/datas';
- $post='phase='.$phase.'&grade='.$gid.'&subject=&colType='.$sid.'&code=&orderby=time&curPage=1&pageSize=9';
- $info=json_decode(get_data($url,$header,$post));
- $moocUrl=$info->data->list[0]->moocUrl;
- $str=file_get_contents($moocUrl,false,$headers);
- preg_match_all('/href="(\/nodedetailcontroller\/.*?)">/',$str,$urls);
- preg_match_all('/break-word;">(.*?\d.*?)</',$str,$title);
- if($id=='list'){
- $result=str_replace(['/nodedetailcontroller/visitnodedetail','courseId','knowledgeId'],['','cid','id'],$urls[1]);
- $n=count($title[1]);
- for($m=0;$m<$n;$m++){
- echo $title[1][$m].',http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].$result[$m].'&gid='.$gid.'&sid='.$sid.'&tag='.$gids[$gid].$sids[$sid].'</a><br>';
- }
- }
- if($id==null){
- $pam=$urls[1][array_rand($urls[1],1)];
- }
- }
- if($id!=='list'&&$id!==''){
- $cid = isset($_GET['cid'])?$_GET['cid']:'214713773';
- if(!empty($cid)){
- $pam='/nodedetailcontroller/visitnodedetail?courseId='.$cid.'&knowledgeId='.$id;
- }
- }
- if($pam){
- $newurl='http://mooc1.chaoxing.com'.$pam;
- $str=file_get_contents($newurl,false,$headers);
- preg_match('/objectid":"(.*?)",/',$str,$data);
- if($data){
- $strurl='http://mooc1.chaoxing.com/ananas/status/'.$data[1].'?k=1467&flag=normal';
- $http=json_decode(get_data($strurl,$header))->http;
- $playurl=str_replace('s1.','s3.',$http);
- //print_r($playurl);
- header('location:'.$playurl);
- }
- }
- function get_data($url,$header,$post=null){
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- if(!empty($post)){
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
- }
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- $data = curl_exec($ch);
- curl_close($ch);
- return $data;
- }
复制代码
提供附件,免回复下载:
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|