1. 程式人生 > >yy4480網站電影真實地址解析【程式碼】

yy4480網站電影真實地址解析【程式碼】

 <?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);
?>