美拍解析源码

1.  <?php   
2.  echo json\_encode(MeiPai::parse($url));  
3.  /\*\* 
4.  \*  
5.  \*/  
6.  class MeiPai  
7.  {  
8.      public static function parse($url){  
9.          $content = self::curl($url);  
10.          preg\_match('#<title>(.\*?)</title>#’,$content,$\_title);  
11.          preg\_match('#<meta content=“(.\*?)" property=“og:image"\>#’,$content,$\_img);  
12.          preg\_match('#data-video=“(.\*?)"#’,$content,$\_video);  
13.          $vurl = self::decode($\_video\[1\]);  

15.          $videoinfo\[“poster"\] = $\_img\[1\];  
16.          $videoinfo\['code’\] = 200;  
17.          $videoinfo\[“data"\]\[“url"\] = $vurl;  
18.          $videoinfo\[“play"\] = “h5mp4";  
19.          return $videoinfo;  
20.      }  
21.      public static function decode($string){  
22.          $hex = str\_split(hexdec(implode(array\_Reverse(str\_split(substr($string,0,4))))));  
23.          $splt1 = $hex\[0\];  
24.          $size1 = $hex\[1\];  
25.          $size2 = $hex\[3\];  
26.          $str = substr($string,4);  
27.          $first = substr($str,0,$splt1).substr($str,$splt1+$size1);  
28.          $splt2 = strlen($first) – ($hex\[2\]) – $size2;  
29.          $second = substr($first,0,$splt2).substr($first,$splt2+$size2);  
30.          return base64\_decode($second);  
31.      }  
32.      public static function curl($url)  
33.      {  
34.          $params\[“ua"\] = “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36";  
35.          return GlobalBase::curl($url,$params);  
36.      }  
37.  }  
38.  ?>