PHP获取蓝奏/158pan/城通网盘直链源码

PHP获取蓝奏云直链的源码案例
可以用来做api调用到网站做下载
演示地址:https://www.99r.ooo/tools/lanzou/
用法:
直接下载:https://www.99r.ooo/tools/lanzou/?url=https://www.lanzous.com/i1a18af&type=down
输出链接:https://www.99r.ooo/tools/lanzou/?url=https://www.lanzous.com/i1a18af


蓝奏云:

<?php
/**
 * @package Lanzou
 * @author Mlooc
 * @version 1.0.0
 * @link https://mlooc.cn
 */
// 指定允许其他域名访问  
header('Access-Control-Allow-Origin:*');
    function MloocCurl($url,$method,$ifurl,$post_data){
        $UserAgent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36';#设置ua
        $curl = curl_init();
        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;
    }
    if (!empty($_GET['url'])) {
        $url = $_GET['url'];
        #第一步
        $ruleMatchDetailInList = "~ifr2\"\sname=\"[\s\S]*?\"\ssrc=\"\/(.*?)\"~";
        preg_match($ruleMatchDetailInList, MloocCurl($url,null,null,null),$link);
        $ifurl = "https://www.lanzous.com/".$link[1];
        #第二步
        $ruleMatchDetailInList = "~=\s'(.*?)';[\S\s]*?=\s'(.*?)'[\S\s]*?=\s'(.*?)'[\S\s]*?=\s'(.*?)'~";
        preg_match($ruleMatchDetailInList, MloocCurl($ifurl,null,null,null),$segment);
        #第三步
        #post提交的数据
        $post_data = array(
            "action" => $segment[1],
            "file_id" => $segment[2],
            "t" => $segment[3],
            "k" => $segment[4]
            );
        $obj = json_decode(MloocCurl("https://www.lanzous.com/ajaxm.php","post",$ifurl,$post_data));#json解析
        if ($obj->dom == "") {#判断链接是否正确
            echo "链接有误!";
        }else{
            $downUrl = $obj->dom."/file/".$obj->url;
            if (!empty($_GET['type'])) {
                $type = $_GET['type'];
                if ($type == "down") {
                    header('Location:'.$downUrl);#直接下载
                }else{
                    echo $obj->dom."/file/".$obj->url;#输出直链
                }
            }else{
                echo $obj->dom."/file/".$obj->url;#输出直链
            }
        }
    }else{
        $result_url = str_replace("index.php","","//".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?url=https://www.lanzous.com/i19zisb");
        echo "示列:";
        echo "<br/>";
        echo "直接下载:"."<a href='".$result_url."&type=down' target='_blank'>".$result_url."&type=down</a>";
        echo "<br/>";
        echo "输出直链:"."<a href='".$result_url."' target='_blank'>".$result_url."</a>";
    }
?>

158Pan:

<?php
/**
 * @package 158Pan
 * @author Mlooc
 * @version 1.0.0
 * @link https://mlooc.cn
 */
// 指定允许其他域名访问  
header('Access-Control-Allow-Origin:*');
    function object_array($array) {  
        if(is_object($array)) {  
            $array = (array)$array;  
        } if(is_array($array)) {  
            foreach($array as $key=>$value) {  
                $array[$key] = object_array($value);  
            }  
        }  
        return $array;  
    }
    function MloocCurl($post_data){
        $UserAgent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36';#设置UserAgent
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, "http://api.baizhu.cc/api/getinfo");
        curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
        #关闭SSL
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        #返回数据不直接显示
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_POST, 1); 
        curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
        $response = curl_exec($curl);
        curl_close($curl);
        return $response;
    }
    if (!empty($_GET['id'])) {
        $id = $_GET['id'];
        $post_data='js={"appid":"307","getlist":{"c1":1,"inslog":"","proc":null,"reg":[{"id":25},{"id":39},{"id":45},{"id":69},{"id":203},{"id":213}]},"id":2052,"mac":"2C-FD-A1-7B-7E-11","md5":"CF517D077E9C152120787EB6B251615B","msoft":"LG%E5%8A%A9%E6%89%8B5.8%E5%AF%86%E7%A0%81666%40307_112837.exe","rgn":"","sid":"'.$id .'","st":0,"ver":"2.2.1.207","zn":8}';
        $result = json_decode(MloocCurl($post_data,true));
        $result = object_array($result);
        $downUrl = $result["main"]["descr_downurl"];
        header('Location:'.$downUrl);
    }else{
        $result_url = str_replace("index.php","","//".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?id=113249");
        echo "演示:";
        echo "<br/>";
        echo "<br/>";
        echo '<a href="'.$result_url.'" target="_blank">'.$result_url.'</a>';
    }
?>

城通网盘:

<?php
/**
 * @package ctdisk
 * @author Mlooc
 * @version 1.0.0
 * @link https://mlooc.cn
 */
// 指定允许其他域名访问  
header('Access-Control-Allow-Origin:*');
    function object_array($array) {  
        if(is_object($array)) {  
            $array = (array)$array;  
        } if(is_array($array)) {  
            foreach($array as $key=>$value) {  
                $array[$key] = object_array($value);  
            }  
        }  
        return $array;  
    }

    function MloocCurl($url){
        $UserAgent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36';#设置UserAgent
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
        #关闭SSL
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        #返回数据不直接显示
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $response = curl_exec($curl);
        curl_close($curl);
        return $response;
    }
    if (!empty($_GET['url'])) {
        $url = $_GET['url'];
        
        $urlInfo = MloocCurl($url);

        $ruleMatchDetailInList = "~var userid = '(.*?)'~";#正则表达式
        preg_match($ruleMatchDetailInList,$urlInfo,$userid);

        $ruleMatchDetailInList = "~onclick=\"free_down\('(.*?)', 0, '(.*?)', 0, 0\)\" id=\"free_down_link\">~";#正则表达式
        preg_match($ruleMatchDetailInList,$urlInfo,$downInfo);
        $userid=$userid[1];
        $file_chk=$downInfo[2];
        $fid=$downInfo[1];

        $url="https://mlooc.ctfile.com/get_file_url.php?uid=".$userid."&fid=".$fid."&file_chk=".$file_chk;
        $downInfo=MloocCurl($url);
        // $downUrl = $result["main"]["descr_downurl"];
        $downInfo=json_decode($downInfo);
        $downInfo=object_array($downInfo);
        print_r($downInfo["downurl"]);
    }else{
        $result_url = str_replace("index.php","","//".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?url=https://u17877708.ctfile.com/fs/17877708-297837876");
        echo "演示:";
        echo "<br/>";
        echo "<br/>";
        echo '<a href="'.$result_url.'" target="_blank">'.$result_url.'</a>';
    }
?>
转自Mlooc
最后修改:2019 年 07 月 21 日 11 : 21 AM
如果觉得我的文章对你有用,请随意赞赏

发表评论