yy4480网站电影真实地址解析【代码】

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhongyuchuan147/article/details/53219900
 <?php
//电影解析
//采集网站yy4480电影网
//使用方法电影解析yy4480.php?url='数字参数'
//电视剧解析yy4480.php?url='数字参数'&number=1
error_reporting(0);
        $s_analysis_url=isset($_GET['url'])?$_GET['url']:'';
        $s_analysis_url=$s_analysis_url.'.html';
        $number=isset($_GET['number'])?$_GET['number']:'';
        if($s_analysis_url==''){
         echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
            echo '填写url';
            exit;
        }
//----------------------------------------------------------------------------
// function getrealurl($url){
// $header = get_headers($url,1);
// if (strpos($header[0],'301') || strpos($header[0],'302')) {
//     if(is_array($header['Location'])) {
//         return $header['Location'][count($header['Location'])-1];
//     }else{
//         return $header['Location'];
//     }
// }else {
//  return $url;
// }
// }();


//解析mp4原地址方法封装

function get_head($sUrl) {
    $oCurl = curl_init();
// 设置请求头, 有时候需要,有时候不用,看请求网址是否有对应的要求
    $header[] = "Content-type: application/x-www-form-urlencoded";
    $user_agent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36";
    curl_setopt($oCurl, CURLOPT_URL, $sUrl);
    curl_setopt($oCurl, CURLOPT_HTTPHEADER, $header);

    curl_setopt($oCurl, CURLOPT_HEADER, true);

    curl_setopt($oCurl, CURLOPT_NOBODY, true);

    curl_setopt($oCurl, CURLOPT_USERAGENT, $user_agent);
    curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($oCurl, CURLOPT_POST, false);

    $sContent = curl_exec($oCurl);
// 获得响应结果里的:头大小
    $headerSize = curl_getinfo($oCurl, CURLINFO_HEADER_SIZE);
// 根据头大小去获取头信息内容
    $header = substr($sContent, 0, $headerSize);

    curl_close($oCurl);
    // $headers=isset(explode('Location:',$header)[1]);
    return $header;
}
//--------------------------------------------------
//电视剧解析
if($number){
        $content='http://s4yy.com/video/'.$s_analysis_url;//地址拼接
        $contents = file_get_contents($content);//载入缓存
        $contents=explode('object',$contents);
        $contents=explode('lists',$contents[2]);
        $contents=explode('"',$contents[1]);
        $contents=explode('https',$contents[0]);
        // echo $contents[1];exit;
        // 加载Xml文件
        $name=file_get_contents('http'.$contents[1]);  //已解析的地址
        // var_dump($name);
        // var_dump($contents);exit;
        $contents = file_get_contents('http'.$contents[1]);
         $contents=explode('src=',$contents);
         // var_dump($contents);exit;
         // $contents=explode('"',$contents[2]);
         var_dump($contents);exit;

// 解析原方法
      //如果解析失败继续解析
      // if(strpos($contents[1],'}')){     //使用绝对等于
      //      $contents=explode('}',$contents[1]);
      //      $v= file_get_contents('http://4480.s4yy.com/levip/'.$contents[1]);//载入缓存
      //      echo '接口码'.$contents[1];
      //      if($v=='vid'){
      //           $v= file_get_contents('http://iqiyi.s4yy.com/iqiyivip_open/'.$contents[1]);//二次载入缓存
      //           if(strpos($v,'error') or strpos($v,'specified')){
      //               $ar='http://4480.s4yy.com/mgtv/'.$contents[1];
      //           }else if(strpos($v,'cuowuid')){
      //               $ar='http://4480.s4yy.com/mgtv/'.$contents[1];
      //           }else{
      //               $ar='http://iqiyi.s4yy.com/iqiyivip_open.php/'.$contents[1];
      //          }
      //      }else{
      //              $ar='http://4480.s4yy.com/levip/'.$contents[1];
      //       }
      //   }else{
      //             $ar=$contents[1];
      //   }
      //   $contents = file_get_contents($ar);
      //   var_dump($contents);exit;
      //   $contents=explode('src',$contents);
      //   for($i=1;$i<count($contents)-1;$i++){
      //     $arr[$i]=explode('"',$contents[$i])[1];
      //   }
      //   var_dump($arr);
      // exit;
}
//--------------------------------------------------

//----------------------------------------------------------------------------
//电影解析
        $content='http://s4yy.com/video/'.$s_analysis_url;//地址拼接
        $contents = file_get_contents($content);//载入缓存
        $contents=explode('object',$contents);
        $contents=explode('lists',$contents[2]);
        $contents=explode('"',$contents[1]);
        $contents=explode('https',$contents[0]);
        $contents = file_get_contents('http'.$contents[1]);
        $contents=explode('src',$contents);
        $contents=explode('"',$contents[1]);

      //如果解析失败继续解析
      if(strpos($contents[1],'}')){     //使用绝对等于
          echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
           $contents=explode('}',$contents[1]);
          $v= file_get_contents('http://4480.s4yy.com/levip.php?vs='.$contents[1]);//载入缓存
           // echo '接口码'.$contents[1];
           if($v=='vid'){
                $v= file_get_contents('http://iqiyi.s4yy.com/iqiyivip_open.php?tvids='.$contents[1]);//二次载入缓存
                if(strpos($v,'error')){
                    $v= file_get_contents('http://4480.s4yy.com/mgtv.php?v='.$contents[1]);//载入缓存
                    if(strpos($v,'cuowuid')){
                      $ar='http://iqiyi.s4yy.com/iqiyivip_open.php?tvids='.$contents[1];
                      // echo 'http://iqiyi.s4yy.com/iqiyivip_open.php?tvids='.$contents[1];
                    }else{
                      $s=file_get_contents('http://4480.s4yy.com/mgtv.php?v='.$contents[1]);
                      if(strpos($s,'busy')){
                              $ar='http://4480.s4yy.com/mgtv.php?v='.$contents[1];
                      }else{
                              $ar=get_head('http://4480.s4yy.com/mgtv.php?v='.$contents[1]);
                      }
                    // echo 'http://4480.s4yy.com/mgtv.php?v='.$contents[1];
                    }
                }else if(strpos($v,'cuowuid')){
                  $ar='http://iqiyi.s4yy.com/iqiyivip_open.php?tvids='.$contents[1];;
                    // echo 'http://iqiyi.s4yy.com/iqiyivip_open.php?tvids='.$contents[1];
                }else{
                  $ar='http://iqiyi.s4yy.com/iqiyivip_open.php?tvids='.$contents[1];
                // echo 'http://iqiyi.s4yy.com/iqiyivip_open.php?tvids='.$contents[1];
            }
           }else{
                $ar='http://4480.s4yy.com/levip.php?vs='.$contents[1];
                // echo 'http://4480.s4yy.com/levip.php?vs='.$contents[1];
            }
        }else{

              if(strpos($contents[1],'iqiyivip_open')){
                  $ar=$contents[1];
             }else{
              $arr=get_head($contents[1]);
              $ar=isset(explode('Location:',$arr)[1])?explode('Location:',$arr)[1]:'';
            }
        }
        echo $ar;
        exit;
        $ar=get_head($ar);
        echo $ar;
        exit;


exit;

        echo $contents[5];
        $contents=explode('https',$contents[5]);
        // $contents = file_get_contents($contents[5]);//载入缓存

        $contents='http'.$contents[1].$contents[2];
        $contents = file_get_contents($contents);//载入缓存

        var_dump($contents);
        // var_dump($contents);
?>

猜你喜欢

转载自blog.csdn.net/zhongyuchuan147/article/details/53219900