Btjson博客 Btjson博客

美拍解析源码(参考)

in 技术文章 read (492) 文章转载请注明来源!

只提供参考,自行测试更多资源交流群516722628

<?php 
echo json_encode(MeiPai::parse($url));
/**
* 
*/
class MeiPai
{
    public static function parse($url){
        $content = self::curl($url);
        preg_match('#<title>(.*?)</title>#',$content,$_title);
        preg_match('#<meta content="(.*?)" property="og:image">#',$content,$_img);
        preg_match('#data-video="(.*?)"#',$content,$_video);
        $vurl = self::decode($_video[1]);

        $videoinfo["poster"] = $_img[1];
        $videoinfo['code'] = 200;
        $videoinfo["data"]["url"] = $vurl;
        $videoinfo["play"] = "h5mp4";
        return $videoinfo;
    }
    public static function decode($string){
        $hex = str_split(hexdec(implode(array_Reverse(str_split(substr($string,0,4))))));
        $splt1 = $hex[0];
        $size1 = $hex[1];
        $size2 = $hex[3];
        $str = substr($string,4);
        $first = substr($str,0,$splt1).substr($str,$splt1+$size1);
        $splt2 = strlen($first) - ($hex[2]) - $size2;
        $second = substr($first,0,$splt2).substr($first,$splt2+$size2);
        return base64_decode($second);
    }
    public static function curl($url)
    {
        $params["ua"] = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36";
        return GlobalBase::curl($url,$params);
    }
}
?>
jrotty WeChat Pay

微信打赏

jrotty Alipay

支付宝打赏

文章二维码

扫描二维码,在手机上阅读!

本文基于《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权
文章链接:https://www.pohaier.com/2018/12/04/138.html (转载时请注明本文出处及文章链接)

技术文章
发表新评论
博客已萌萌哒运行
© 2019 由 Typecho 强力驱动.Theme by btjson
PREVIOUS NEXT
雷姆
拉姆