正文

爱奇艺解析源码

爱奇艺解析源码

  1. <?php   
  2. echo Iqiyi::parse($url);  
  3.   
  4. class Iqiyi  
  5. {  
  6.     /** 
  7.      * [parse 解析网页获取视频ID] 
  8.      * @param  [type] $url  [description] 
  9.      * @return [type]       [description] 
  10.      */  
  11.     public static function parse($url)  
  12.     {  
  13.         $html = self::curl($url);  
  14.   
  15.         if($html){  
  16.             preg_match('#vid“:"(.*)“,#iU’,$html,$vids); 
  17.             preg_match('#tvId":(.*),“#iU’,$html,$tvids); 
  18.             preg_match('#param\[\’isMember\’\]\s*=\s*"(.*)“;#’,$html,$bool); 
  19.             preg_match('#tvName:"(.*)“#iU’,$html,$tvName); 
  20.             preg_match('#property="og:image“\s*content="(.*)“#’,$html,$images); 
  21.             if (!$vids[1]) { 
  22.                 preg_match('#data-player-videoid="(.*)“#iU’,$html,$vids); 
  23.             } 
  24.             if (!$tvids[1]) { 
  25.                 preg_match('#data-player-tvid="(.*)“#iU’,$html,$tvids); 
  26.             } 
  27.             if (!$tvName[1]) { 
  28.                 preg_match('#name="irTitle“\s*content="(.*)“#’,$html,$tvName); 
  29.             } 
  30.             $ids['uid’] = empty($_uid[1])?"“:$_uid[1];                          //用户需从cookie里P00010获取,请自行修改 
  31.             $ids['qyid’] = empty($_qyid[1])? “d56mj2ujli317a4mvdxq5i73“:$_qyid[1];//用户需从cookie里QC006获取,请自行修改 
  32.             $ids['agenttype’] = 13; 
  33.             $ids['type’] = 'mp4’; 
  34.             $time = number_format(microtime(true),3,","); 
  35.             $ids['sgti’] = “{$ids['agenttype’]}_{$ids['qyid’]}_{$time}“; 
  36.  
  37.             $ids['title’] = $tvName[1]; 
  38.             $ids['member’] = $bool[1];//是否为付费视频 
  39.             $ids['vid’] = $vids[1]; 
  40.             $ids['tvid’] = $tvids[1]; 
  41.             $ids['image’] = isset($images[1]) ? $images[1] : "; 
  42.             $ids['src’] = '02020031010000000000’; 
  43.             $ids['url’] = $url; 
  44.             $ids['ref’] = $url; 
  45.  
  46.             $api = 'https://mixer.video.iqiyi.com/jp/mixin/videos/’.$ids['tvid’]; 
  47.             $html = self::curl($api,$ids); 
  48.             $html = str_replace('var tvInfoJs=’,",$html); 
  49.             $json = json_decode($html,true); 
  50.  
  51.             $ids['title’] = isset($json['name’]) ? $json['name’] : $ids['title’]; 
  52.             $ids['des’] = isset($json['des’]) ? $json['des’] : $ids['des’]; 
  53.             $ids['poster’] = isset($json['imageUrl’]) ? str_replace(“.jpg“, “_480_270.jpg“,$json['imageUrl’]) : str_replace(“.jpg“, “_480_270.jpg“,$ids['image’]) ;  
  54.  
  55.             //print_r($ids);exit; 
  56.  
  57.             // 
  58.             // 
  59.             // 
  60.             $videoinfo = self::get_video($ids); 
  61.             return json_encode($videoinfo); 
  62.         } 
  63.  
  64.     } 
  65.     /** 
  66.      * [get_tmts_video 解析视频地址] 
  67.      * @param  [type] $tvid [description] 
  68.      * @param  [type] $vid  [description] 
  69.      * @return [type]       [description] 
  70.      */ 
  71.     public static function get_video($ids) 
  72.     { 
  73.         if($ids['member’]===’true’){//付费视频 
  74.             $url = './yun/?url=’.$ids['url’]; 
  75.             $videoinfo['code’] = 200; 
  76.             $videoinfo['play’] = 'iframe’; 
  77.             //$videoinfo['msg’] = $ids['title’] . '为爱奇异VIP资源!VIP资源全网搜索中….’; 
  78.             $videoinfo['data’]['url’] = $url;  
  79.             return $videoinfo;exit; 
  80.         }else{ 
  81.             $api = self::get_tmts_data($ids); 
  82.             $ids['cookie’] = 'P00001=’; 
  83.             $content = self::curl($api,$ids); 
  84.         } 
  85.  
  86.         $body = preg_replace(“#var tvInfoJs=#“,"“,$content); 
  87.  
  88.         $json = json_decode($body,true); 
  89.         //print_r($json);exit; 
  90.  
  91.         if ($json['code’]==’A00000′ && isset($json['data’])){ 
  92.             $data = $json['data’]; 
  93.             $vidl = $data['vidl’];              //视频地址列表 
  94.                 $datainfo['code’] = 200; 
  95.                 $datainfo['play’] = 'ajax’; 
  96.                 $datainfo['type’] = 'iqiyi’; 
  97.                 $datainfo['msg’] = "; 
  98.                 $datainfo['data’][“vid“] = $ids['vid’]; 
  99.                 $datainfo['data’][“tvid“] = $ids['tvid’]; 
  100.                 $datainfo['data’][“uid“] = $ids['uid’]; 
  101.                 $datainfo['data’][“qyid“] = $ids['qyid’]; 
  102.                 $datainfo['data’][“type“] = $ids['type’]; 
  103.                 $datainfo['data’][“src“] = $ids['src’]; 
  104.                 $datainfo['data’][“agenttype“] = $ids['agenttype’]; 
  105.                 $datainfo['data’][“jsdir“] = GlobalBase::https_url().’/static’; 
  106.                 $datainfo['data’][“poster“] = $ids['poster’]; 
  107.  
  108.         } 
  109.         return $datainfo; 
  110.     } 
  111.     public static function get_tmts_url($ids) {//付费视频提交cookie 
  112.         preg_match('#P00010=(\d+);#iU’,COOKIE_IQIYI,$_uid); 
  113.         preg_match('#QC006=(.*);#iU’,COOKIE_IQIYI,$_qyid); 
  114.         $domain = “http://cache.m.iqiyi.com";  
  115.         $uid = emptyempty($_uid[1])?"“:$_uid[1];                         //用户需从cookie里P00010获取,请自行修改 
  116.         $qyid = empty($_qyid[1])? “d56mj2ujli317a4mvdxq5i73“:$_qyid[1];//用户需从cookie里QC006获取,请自行修改 
  117.         $agenttype = 13; 
  118.         $time = number_format(microtime(true),3,","); 
  119.         $type = $_REQUEST['isphone’] == 0 ? 'm3u8′:’mp4’; 
  120.         $tm = mb_substr($time,0,11); 
  121.         $sgti = “{$agenttype}_{$qyid}_{$time}“; 
  122.         $src = '1702633101b340d8917a69cf8a4b8c7c’ ; // “02020031010000000000“; 
  123.         $tmtsreq = “/jp/tmts/“.$ids['tvid’]."/“.$ids['vid’]."/?uid={$uid}&cupid=qc_100001_100186&platForm=h5&qyid={$qyid}&agenttype={$agenttype}&type={$type}&rate=2&sgti={$sgti}&qdv=1&qdx=n&qdy=x&qds=0&tm={$tm}&src={$src}“;//platForm=PHONE 
  124.         $vf= md5($tmtsreq."t6hrq6k0n6n6k6qdh6tje6wpb62v7654“); //参数校验码 
  125.         $url = $domain.$tmtsreq."&vf={$vf}“; 
  126.  
  127.         //echo $url;eixt; 
  128.  
  129.         return $url; 
  130.     } 
  131.  
  132.     public static function get_mp4_data($ids) {//付费视频提交cookie 
  133.         preg_match('#P00010=(\d+);#iU’,COOKIE_IQIYI,$_uid); 
  134.         preg_match('#QC006=(.*);#iU’,COOKIE_IQIYI,$_qyid); 
  135.         $domain = “http://cache.m.iqiyi.com";  
  136.         $uid = emptyempty($_uid[1])?"“:$_uid[1];                         //用户需从cookie里P00010获取,请自行修改 
  137.         $qyid = empty($_qyid[1])? “d56mj2ujli317a4mvdxq5i73“:$_qyid[1];//用户需从cookie里QC006获取,请自行修改 
  138.         $agenttype = 13; 
  139.         $time = number_format(microtime(true),3,","); 
  140.         $type = $_REQUEST['isphone’] == 0 ? 'm3u8′:’mp4’; 
  141.         $tm = mb_substr($time,0,11); 
  142.         $sgti = “{$agenttype}_{$qyid}_{$time}“; 
  143.         $src=’02020031010010000000′; 
  144.         $a=’/tmts/’.$ids['tvid’].’/’.$ids['vid’].’/?uid=&platForm=h5&agenttype=13&type=mp4&k_ft1=8&rate=2&p=&codeflag=1&qdv=1&qdx=n&qdy=x&qds=0&t=’.$tm.’&src=’.$src; 
  145.         $vf=md5($a.’3sj8xof48xof4tk9f4tk9ypgk9ypg5ul’); 
  146.         $api=’http://cache.m.iqiyi.com’.$a.’&vf=’.$vf; 
  147.         return $api; 
  148.     } 
  149.  
  150.     public static function get_tmts1_url($ids) { 
  151.         preg_match('#P00010=(\d+);#iU’,COOKIE_IQIYI,$_uid); 
  152.         preg_match('#QC006=(.*);#iU’,COOKIE_IQIYI,$_qyid); 
  153.         $domain = “https://cache.m.iqiyi.com";  
  154.         $uid = emptyempty($_uid[1])?"“:$_uid[1];                         //用户需从cookie里P00010获取,请自行修改 
  155.         $qyid = empty($_qyid[1])? “d56mj2ujli317a4mvdxq5i73“:$_qyid[1];//用户需从cookie里QC006获取,请自行修改 
  156.         $agenttype = 13; 
  157.         $time = number_format(microtime(true),3,","); 
  158.  
  159.         $type = $_REQUEST['isphone’] == 0 ? 'm3u8′:’mp4’; 
  160.         $tm = mb_substr($time,0,11); 
  161.         $sgti = “{$agenttype}_{$qyid}_{$time}“; 
  162.         $src = “02020031010000000000“; 
  163.         $authkey = md5(".$time.$tvid); 
  164.         $tmtsreq = “/jp/tmts/“.$ids['tvid’]."/“.$ids['vid’]."/?uid=&cupid=qc_100001_100186&platForm=h5&qyid=“.$qyid."&agenttype=13&type=mp4&nolimit=&k_ft1=8&rate=2&sgti=“.$sgti."&codeflag=1&preIdAll=&qd_v=1&qdy=a&qds=0&tm=“.$tm."&src=02020031010000000000“;//platForm=PHONE 
  165.  
  166.         $vf= md5($tmtsreq."u6fnp3eok0dpftcq9qbr4n9svk8tqh7u“); //参数校验码 
  167.         $url = $domain.$tmtsreq."&vf={$vf}“; 
  168.  
  169.         return $url; 
  170.     } 
  171.     public static function get_tmts2_url($ids) {//付费视频提交cookie 
  172.         preg_match('#P00010=(\d+);#iU’,COOKIE_IQIYI,$_uid); 
  173.         preg_match('#QC006=(.*);#iU’,COOKIE_IQIYI,$_qyid); 
  174.         $domain = “http://cache.m.iqiyi.com";  
  175.         $uid = emptyempty($_uid[1])?"“:$_uid[1];                         //用户需从cookie里P00010获取,请自行修改 
  176.         $qyid = empty($_qyid[1])? “d56mj2ujli317a4mvdxq5i73“:$_qyid[1];//用户需从cookie里QC006获取,请自行修改 
  177.         $agenttype = 12; 
  178.         $time = number_format(microtime(true),3,","); 
  179.         $type = $_REQUEST['isphone’] == 0 ? 'm3u8′:’mp4’; 
  180.         $tm = mb_substr($time,0,11); 
  181.         $sgti = “{$agenttype}_{$qyid}_{$time}“; 
  182.         //$src = “02020031010000000000“; 
  183.         //$tmtsreq = “/jp/tmts/{$tvid}/{$vid}/?uid={$uid}&cupid=qc_100001_100186&platForm=h5&qyid={$qyid}&agenttype={$agenttype}&type={$type}&rate=2&sgti={$sgti}&qdv=1&qdx=n&qdy=x&qds=0&tm={$tm}&src={$src}“;//platForm=PHONE 
  184.         //$vf= md5($tmtsreq."3sj8xof48xof4tk9f4tk9ypgk9ypg5ul“); //参数校验码 
  185.  
  186.         $t = time(); 
  187.         $k = “d5fb4bd9d50c4be6948c97edd7254b0e“; 
  188.         $src = “76f90cbd92f94a2e925d83e8ccd22cb7“; 
  189.         $sc=md5($t.$k.$vid); 
  190.         $url=’http://cache.m.iqiyi.com/jp/tmts/’.$ids['tvid’].’/’.$ids['vid’].’/?t=’.$t.’&sc=’.$sc.’&src=’.$src; 
  191.         return $url; 
  192.     } 
  193.     public static function get_app_data($ids) {  //app端的vf算法 
  194.         preg_match('#P00010=(\d+);#iU’,COOKIE_IQIYI,$_uid); 
  195.         preg_match('#QC006=(.*);#iU’,COOKIE_IQIYI,$_qyid); 
  196.  
  197.         $uid = empty($_uid[1])?"“:$_uid[1];      
  198.  
  199.         $platForm = “h5“; 
  200.  
  201.         $agenttype = “13“; 
  202.  
  203.         $type = “m3u8“; 
  204.  
  205.         $nolimit = 0; 
  206.  
  207.         $k_ft1 = 8; 
  208.  
  209.         $rate = 4; 
  210.  
  211.         $p = ““; 
  212.  
  213.         $codeflag = “1“; 
  214.  
  215.         $qdv = “1“; 
  216.  
  217.         $qdx = “n“; 
  218.  
  219.         $qdy = “x“; 
  220.  
  221.         $qds = 0; 
  222.  
  223.         $__jsT = “sgve“; 
  224.  
  225.         $qyid = empty($_qyid[1])? “d56mj2ujli317a4mvdxq5i73“:$_qyid[1];//用户需从cookie里QC006获取,请自行修改 
  226.  
  227.         $time = number_format(microtime(true),3,","); 
  228.  
  229.         $tm = mb_substr($time,0,11); 
  230.  
  231.         $sgti = “{$agenttype}_{$qyid}_{$time}“; 
  232.  
  233.         $src = “02028001010000000000“; 
  234.  
  235.         $tmtsreq = “/tmts/“.$ids['tvid’]."/“.$ids['vid’]."/?uid={$uid}&platForm={$platForm}&agenttype={$agenttype}&qyid={$qyid}&platForm=IPHONE&type={$type}&nolimit={$nolimit}&k_ft1={$k_ft1}&rate={$rate}&p={$p}&codeflag={$codeflag}&qdv={$qdv}&qdx={$qdx}&qdy={$qdy}&qds={$qds}&__jsT={$__jsT}&t={$tm}&src={$src}“; 
  236.  
  237.         $vf= md5($tmtsreq."3sj8xof48xof4tk9f4tk9ypgk9ypg5ul“); //参数校验码 
  238.         $url = 'https://cache.m.iqiyi.com’.$tmtsreq."&vf={$vf}“; 
  239.         //echo $url;exit; 
  240.  
  241.         return $url; 
  242.     } 
  243.  
  244.     public static function get_vps_data($ids){ //pc 端接口 
  245.         preg_match('#P00010=(\d+);#iU’,COOKIE_IQIYI,$_uid); 
  246.         preg_match('#QC006=(.*);#iU’,COOKIE_IQIYI,$_qyid); 
  247.  
  248.         $host = 'http://cache.video.qiyi.com’; 
  249.  
  250.         $src = '/vps?tvid=’.$ids['tvid’].’&vid=’.$ids['vid’].’&v=0&qypid=’.$ids['tvid’].’_12&src=1702633101b340d8917a69cf8a4b8c7c&platforms=PC_APP&t=’.GlobalBase::getMillisecond().’&k_tag=1&type=mp4&k_uid=’.self::get_macid().’&rs=1′; 
  251.  
  252.         //$vf = self::get_vf($src); 
  253.         $vf= md5($src."u6fnp3eok0dpftcq9qbr4n9svk8tqh7u“); 
  254.  
  255.         $api = $host . $src . '&vf=’ . $vf; 
  256.  
  257.         if($ids['member’]===’true’){//付费视频 
  258.             $ids['cookie’] = COOKIE_IQIYI; 
  259.             $data = self::curl($api,$ids); 
  260.         }else{ 
  261.             $data = self::curl($api,$ids); 
  262.         } 
  263.  
  264.         //print_r($data);exit; 
  265.  
  266.         $data = json_decode($data,true); 
  267.  
  268.         if ($data['code’] == 'A00000’) { 
  269.             $list = $data['data’]['vp’]['tkl’][0]['vs’]; 
  270.             $dom = $data['data’]['vp’]['du’]; 
  271.             foreach ($list as $key => $value) { 
  272.                 switch ($value['bid’]) { 
  273.                     case 1: 
  274.                         $def = '普清’; 
  275.                         break; 
  276.                     case 2: 
  277.                         $def = '高清’; 
  278.                         break; 
  279.                     case 4: 
  280.                         $def = '超清’; 
  281.                         break; 
  282.                     case 96: 
  283.                         $def = '流畅’; 
  284.                         break; 
  285.                 } 
  286.  
  287.                 foreach ($value['fs’] as $k => $v) { 
  288.                     $a[$k]['file’] = self::get_pc_url_data($dom.$v['l’],$ids); 
  289.                     $a[$k]['duration’] = $v['d’]/1000; 
  290.                     $a[$k]['bytesTotal’] = $v['b’]; 
  291.                 } 
  292.                 if ($value['bid’] == 4) { 
  293.                     $_loc[0]['video’] = $a; 
  294.                     $_loc[0]['type’] = 'mp4’; 
  295.                     $_loc[0]['weight’] = 10; 
  296.                     $_loc[0]['definition’] = $def; 
  297.                 } 
  298.                 if ($value['bid’] == 2) { 
  299.                     $_loc[1]['video’] = $a; 
  300.                     $_loc[1]['type’] = 'mp4’; 
  301.                     $_loc[1]['weight’] = 10; 
  302.                     $_loc[1]['definition’] = $def; 
  303.                 } 
  304.                 if ($value['bid’] == 1) { 
  305.                     $_loc[2]['video’] = $a; 
  306.                     $_loc[2]['type’] = 'mp4’; 
  307.                     $_loc[2]['weight’] = 10; 
  308.                     $_loc[2]['definition’] = $def; 
  309.                 } 
  310.  
  311.             } 
  312.             for ($i=0; $i <= 2 ; $i++) { 
  313.                 if ($_loc[$i] == ") { 
  314.                 continue; 
  315.             } 
  316.             $key_arrays[]=$_loc[$i]; 
  317.         } 
  318.         } 
  319.         $videoinfo['code’] = 200; 
  320.         $videoinfo['data’]['poster’] = $ids['poster’]; 
  321.         $videoinfo['play’] = 'mp4_list’; 
  322.         $videoinfo['data’]['video’][0] = $key_arrays[0]; 
  323.  
  324.         print_r(json_encode($videoinfo));exit; 
  325.     } 
  326.  
  327.     public static function get_tmts_data($ids){  
  328.         $t = time()*1000; 
  329.         $src = “76f90cbd92f94a2e925d83e8ccd22cb7“; 
  330.         $key = “d5fb4bd9d50c4be6948c97edd7254b0e“; 
  331.         $vid = $ids['vid’]; 
  332.         $tvid = $ids['tvid’]; 
  333.         $sc = md5($t.$key.$vid); 
  334.         $url = “http://cache.m.iqiyi.com/jp/tmts/$tvid/$vid/?t=$t&sc=$sc&src=$src";  
  335.         return $url;  
  336.     }  
  337.   
  338.     public static function get_pc_url_data($url,$ids){  
  339.         $data = file_get_contents($url);  
  340.   
  341.         $data = json_decode($data,true);  
  342.   
  343.         $u = $data['l’];  
  344.         return $u;  
  345.     }  
  346.   
  347.     public static function get_macid(){  
  348.         //"’获取macid,此值是通过mac地址经过算法变换而来,对同一设备不变"’  
  349.         $macid=";  
  350.         $chars = 'abcdefghijklnmopqrstuvwxyz0123456789’;  
  351.         $size = strlen($chars);  
  352.         for ($i=0; $i < 32 ; $i++) {   
  353.             $a = mt_rand(0,($size-1));  
  354.             $macid .= $chars[$a];  
  355.         }  
  356.         return $macid;  
  357.     }  
  358.     public static function get_vf($url_params){  
  359.         $sufix=";  
  360.         for ($i=0; $i <8 ; $i++) {   
  361.             for ($j=0; $j <4 ; $j++) {   
  362.                 $v4 = 13 * (66 * $j + 27 * $i) % 35;  
  363.   
  364.                 if ($v4 >= 10) {  
  365.                     $v8 = $v4 + 88;  
  366.                 } else {  
  367.                     $v8 = $v4 + 49;  
  368.                 }  
  369.   
  370.                 $sufix .= chr($v8);  
  371.   
  372.             }  
  373.             $url_params .= $sufix;  
  374.         }  
  375.         //echo $url_params;exit;  
  376.         $vf = md5($url_params);  
  377.         return $vf;  
  378.     }  
  379.     public static function iqiyi_curl($url$params = array()) {  
  380.         $ip = emptyempty($params[“ip“]) ? GlobalBase::rand_ip() : $params[“ip“];  
  381.         $header = array('X-FORWARDED-FOR:’.$ip,’CLIENT-IP:’.$ip); 
  382.         if(isset($params[“httpheader“])){ 
  383.             $header = array_merge($header,$params[“httpheader“]); 
  384.         } 
  385.         $referer = empty($params[“ref“]) ? $url : $params[“ref“]; 
  386.         $user_agent = empty($params[“ua“]) ? $_SERVER['HTTP_USER_AGENT’] : $params[“ua“] ; 
  387.  
  388.         $ch = curl_init();                                                      //初始化 curl 
  389.         curl_setopt($ch, CURLOPT_URL, $url);                                    //要访问网页 URL 地址 
  390.         curl_setopt($ch, CURLOPT_HTTPHEADER, $header);                          //伪装来源 IP 地址 
  391.         curl_setopt($ch, CURLOPT_REFERER, $referer);                            //伪装网页来源 URL 
  392.         curl_setopt($ch, CURLOPT_USERAGENT,$user_agent);                        //模拟用户浏览器信息 
  393.         curl_setopt($ch, CURLOPT_NOBODY, false);                                //设定是否输出页面内容 
  394.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                         //返回字符串,而非直接输出到屏幕上 
  395.         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, false);                        //连接超时时间,设置为 0,则无限等待 
  396.         curl_setopt($ch, CURLOPT_TIMEOUT, 3600);                                //数据传输的最大允许时间超时,设为一小时 
  397.         curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);                       //HTTP验证方法 
  398.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);                        //不检查 SSL 证书来源 
  399.         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);                        //不检查 证书中 SSL 加密算法是否存在 
  400.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);                         //跟踪爬取重定向页面 
  401.         curl_setopt($ch, CURLOPT_AUTOREFERER, true);                            //当Location:重定向时,自动设置header中的Referer:信息 
  402.         curl_setopt($ch, CURLOPT_ENCODING, ");                                 //解决网页乱码问题 
  403.         curl_setopt($ch, CURLOPT_HEADER, empty($params[“header“])?false:true);  //不返回 header 部分 
  404.         if(!empty($params[“fields“])){ 
  405.             curl_setopt($ch, CURLOPT_POST, true);                                  //设置为 POST  
  406.             curl_setopt($ch, CURLOPT_POSTFIELDS,$params[“fields“]);                //提交数据 
  407.         } 
  408.         if(!empty($params[“cookie“])){ 
  409.             curl_setopt($ch, CURLOPT_COOKIE, $params[“cookie“]);                  //从字符串传参来提交cookies 
  410.         } 
  411.         if(!empty($params[“proxy“])){ 
  412.             curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);                  //代理认证模式 
  413.             curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);                  //使用http代理模式 
  414.             curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);  
  415.             curl_setopt($ch, CURLOPT_PROXY, “58.251.230.220:9797“);   //代理服务器地址 host:post的格式 
  416.             if(!empty($params[“proxy_userpwd“])){ 
  417.                 curl_setopt($ch, CURLOPT_PROXYUSERPWD, $params[“proxy_userpwd“]); //http代理认证帐号,username:password的格式 
  418.             } 
  419.         } 
  420.         $data = curl_exec($ch);                                                 //运行 curl,请求网页并返回结果 
  421.         curl_close($ch);                                                        //关闭 curl 
  422.         return $data; 
  423.     } 
  424.     public static function curl($url,$ids) 
  425.     { 
  426.         $params[“ua“] = !empty($ids['ua’]) ? $ids['ua’] : “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36“; 
  427.         $params[“ip“] = “14.21.98.117“;//伪装为固定IP,否则会报异地登录,会封号,不要更改 
  428.         if (isset($ids['cookie’])) { 
  429.             $params[“cookie“] = $ids['cookie’]; 
  430.         } 
  431.         $params[“ref“] = “https://www.iqiyi.com";  
  432.   
  433.         //$params[“proxy"] = PROXY;  
  434.         //return GlobalBase::iqiyi_curl($url,$params);  
  435.         return self::iqiyi_curl($url,$params);  
  436.     }  
  437. }