分享一个蓝奏云解析源码

前言

有时候我们需要蓝奏云的直链做一些事情,比如远程更新等,所以能够解析直链就比较重要,今天就给大家分享一个解析源码,亲测可用

代码

<?php
/**
 * User: 莫忘
 * Agreement: 新锐博客【www.xrbk.cn】
 * Date: 2024/01/03
 * Time: 12.07
 */
//调用接口:http://localhost/index.php?url=https://xxx.lanzout.com/xxxxxxxx&p=xxxx
header("Content-Type: text/html;charset=utf-8");
//网页访问
function MloocCurl($url, $method, $ifurl, $post_data)
{
    //设置ua
    $UserAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36';
    //初始化cURl
    $curl = curl_init();
    //设置cUrl传输选项
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    if ($method == "post") {
        curl_setopt($curl, CURLOPT_REFERER, $ifurl);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    }
    $response = curl_exec($curl);
    curl_close($curl);
    return $response;
}
//过滤空格换行 
function DeleteHtml($str)
{
    $str = trim($str); //清除字符串两边的空格
    $str = preg_replace("/t/","",$str); //使用正则表达式替换内容,如:空格,换行,并将替换为空。
    $str = preg_replace("/rn/","",$str); 
    $str = preg_replace("/r/","",$str); 
    $str = preg_replace("/n/","",$str); 
    $str = preg_replace("/ /","",$str);
    $str = preg_replace("/  /","",$str);  //匹配html中的空格
    return trim($str); //返回字符串
}
//文本_取出中间文本
function getSubstr($str, $leftStr, $rightStr)
{
    $left = strpos($str, $leftStr);
    $right = strpos($str, $rightStr, $left);
    if ($left < 0 or $right < $left) return '';
    return substr($str, $left + strlen($leftStr), $right - $left - strlen($leftStr));
}
$_SERVER['REQUEST_METHOD']=='GET' ? $api = $_GET : $api = $_POST;
if (!empty($api['url'])) {
    $url = @$api['url'];
    $p = @$api['p'];
    //取出蓝奏云域名
    preg_match("/^(.*://)?([^/]+)/i", $url, $link);
    $domain = $link[0];
    if ($p == "") {
        #没有密码获取方法
        #第一步,取出fn
        $ruleMatchDetailInList = "~src="/fn?([sS]*?)"~";
        $MloocCurl = MloocCurl($url, null, null, null);
        if(mb_strpos(getSubstr($MloocCurl, '<div class="off1"></div></div>', "</div>"),'来晚啦...文件取消分享了') !== false){
            exit (json_encode(['code'=>false,'msg'=>'来晚啦...文件取消分享了'],JSON_UNESCAPED_UNICODE ));
        }
        if(mb_strpos(getSubstr($MloocCurl, '<div class="passwddiv-input">', "</div>"),'输入密码') !== false){
            exit (json_encode(['code'=>false,'msg'=>'参数错误,输入密码'],JSON_UNESCAPED_UNICODE ));
        }
        preg_match_all($ruleMatchDetailInList, $MloocCurl, $link);
        $fn = $link[1][1];
        $ifurl = $domain . "/fn?" . $fn;
        #第二步
        $data = MloocCurl($ifurl, null, null, null);
        $signs = getSubstr($data, "var ajaxdata = '", "';");
        $websign = getSubstr($data, "var websign = '", "';");
        $websignkey = getSubstr($data, "var websignkey = '", "';");
        $sign = getSubstr($data, "'sign':'", "','");
        $post_data = array(
            "action" => "downprocess",
            "signs" => $signs,
            "sign" => $sign,
            "ves" => "1",
            "websign" => $websign,
            "websignkey" => $websignkey,
        );
        $obj = json_decode(MloocCurl($domain . "/ajaxm.php", "post", $ifurl, $post_data)); #json解析
        $nc = getSubstr($MloocCurl, '<div style="font-size: 30px;text-align: center;padding: 56px 0px 20px 0px;">', "</div>");//软件名称
        $ds = getSubstr($MloocCurl, "文件大小:</span>", "<br>");//文件大小
        $yh = getSubstr($MloocCurl, "分享用户:</span><font>", "</font><br>");//分享用户
        $yx = getSubstr($MloocCurl, "运行系统:</span>", "<br>");//运行系统
        $txt = DeleteHtml(strtr(getSubstr(getSubstr($MloocCurl, "文件描述:</span>", "</table>"), "<br>", "</td>"), ['<br />' => '','<br>' => '']));//文件描述
        if ($obj->zt == "1") { #判断链接是否正确
            $downUrl = $obj->dom . "/file/" . $obj->url;
            exit (json_encode(['code'=>true,'msg'=>'获取成功','data'=>['nc'=>$nc,'ds'=>$ds,'yh'=>$yh,'yx'=>$yx,'txt'=>$txt,'url'=>$downUrl]],JSON_UNESCAPED_UNICODE ));
        } else {
            exit (json_encode(['code'=>false,'msg'=>$obj->inf],JSON_UNESCAPED_UNICODE ));
        }
    } else {
        #带密码获取方法
        $ifurl = $url;
        $MloocCurl = MloocCurl($ifurl, null, null, null);
        if(mb_strpos(getSubstr($MloocCurl, '<div class="off1"></div></div>', "</div>"),'来晚啦...文件取消分享了') !== false){
            exit (json_encode(['code'=>false,'msg'=>'来晚啦...文件取消分享了'],JSON_UNESCAPED_UNICODE ));
        }
        if(mb_strpos(getSubstr($MloocCurl, '<div class="passwddiv-input">', "</div>"),'输入密码') === false){
            exit (json_encode(['code'=>false,'msg'=>'参数错误,无需要密码'],JSON_UNESCAPED_UNICODE ));
        }
        $sign = getSubstr($MloocCurl, "var skdklds = '", "';");
        $post_data = array(
            "action" => "downprocess",
            "sign" => $sign,
            "p" => $p,
        );
        $obj = json_decode(MloocCurl($domain . "/ajaxm.php", "post", $ifurl, $post_data)); #json解析
        if ($obj->zt == "1") { #判断链接是否正确
            $nc = $obj->inf;//软件名称
            $ds = getSubstr($MloocCurl, '<div class="n_filesize">大小:', "</div>");//文件大小
            $yh = getSubstr($MloocCurl, "获取<span>", "</span>的文件");//分享用户
            $yx = getSubstr($MloocCurl, '<span class="n_file_infos">', "</span>");//运行系统
            $txt = DeleteHtml(strtr(getSubstr($MloocCurl, '<div class="n_box_des">', "</div>"), ['<br />' => '','<br>' => '']));//文件描述
            $downUrl = $obj->dom . "/file/" . $obj->url;
            exit (json_encode(['code'=>true,'msg'=>'获取成功','data'=>['nc'=>$nc,'ds'=>$ds,'yh'=>$yh,'yx'=>$yx,'txt'=>$txt,'url'=>$downUrl]],JSON_UNESCAPED_UNICODE ));
        } else {
            exit (json_encode(['code'=>false,'msg'=>$obj->inf],JSON_UNESCAPED_UNICODE ));
        }
    }
} else {
    exit (json_encode(['code'=>false,'msg'=>'参数错误'],JSON_UNESCAPED_UNICODE ));
}
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情

    暂无评论内容