[title]获取蓝奏云直链[/title]

国内网盘目前应该大多不支持直链,百度网盘一家独大但是限速,使用api获得的外联也有时效性,蓝奏云这个被众多人推崇的网盘速度还不错,稳定了很长时间了,被很多网站使用,而且最终要的是有办法获取外链的,下面就附上代码和使用说明吧。

[title]使用说明[/title]

[success]使用方法

输出直链:你的域名/url.php?url=蓝奏云链接

直接下载:你的域名/url.php?url=蓝奏云链接&type=down

[/success]

[info]例子:

直接下载:https://cdn.233i.cn/blog/lanzou/url.php?url=https://www.lanzous.com/i1s33fa&type=down

输出直链:https://cdn.233i.cn/blog/lanzou/url.php?url=https://www.lanzous.com/i1s33fa

[/info]

 

[title]url.php文件代码如下[/title]

[cc lang="php"]
/**
* @package Lanzou
* @author lanzou
* @version 1.0.0
* @link https://233i.cn
*/
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 "
";
echo "直接下载:"."".$result_url."&type=down";
echo "
";
echo "输出直链:"."".$result_url."";
}
?>
[/cc]

Last modification:February 17th, 2021 at 09:11 pm
如果觉得我的文章对你有用,请随意赞赏