仅提供PHP代码,且没做测试,具体用途自行适配。
<?php
echo urlpoi('https://lanzoui.com/i9t47cb');
function urlpoi($downurl){
$downarr = parse_url($downurl);
$content = get_curl($downurl, 0, $downurl, 0, 1);
preg_match_all('/iframe(.*?)src="(.*?)" /', $content, $lanzouy);
if (strpos($output,'文件取消分享了') || empty($content)) {
$download = 200;//文件取消分享了
} elseif (strpos($output,'输入密码')) {
$download = 201;//文件需要密码
} elseif (empty($lanzouy [2] [1])) {
$download = 200;//文件需要密码
} else {
$content = get_curl($downarr ['scheme'] . '://' . $downarr ['host'] . $lanzouy [2] [1], 0, $downurl, 'codelen=1; pc_ad1=1;', 1);
preg_match('/var wsk_sign = \'(.*?)\';/', $content, $wsk_sign);
preg_match('/var ws_sign = \'(.*?)\';/', $content, $ws_sign);
preg_match('/var ajaxdata = \'(.*?)\';/', $content, $ajaxdata);
preg_match('/sign\':\'(.*?)\'/', $content, $sign);
$content = get_curl(
$downarr ['scheme'] . '://' . $downarr ['host'] . '/' . 'ajaxm.php'
, 'action=downprocess&signs=' . urlencode($ajaxdata [1]) . '&sign=' . $sign [1] . '&websign=' . $ws_sign [1] . '&websignkey=' . $wsk_sign [1] . '&ves=1'
, $downarr ['scheme'] . '://' . $downarr ['host'] . $lanzouy [2] [1]
, 'codelen=1; pc_ad1=1;'
, 0
, 0
, 0
, ['Content-Type: application/x-www-form-urlencoded']
);
$array = json_decode($content);
$download = $array->dom . '/file/' . $array->url;
}
return $download;
}
function get_curl($url,$post=0,$referer=1,$cookie=0,$header=0,$ua=0,$nobaody=0,$addheader=0){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader [] = "Accept: application/json";
//$httpheader [] = "Accept-Encoding: gzip,deflate,sdch";
$httpheader [] = "Accept-Language: zh-CN,zh;q=0.8";
$httpheader [] = "Connection: close";
if($addheader){
$httpheader = array_merge($httpheader, $addheader);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
if($post){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if($header){
curl_setopt($ch, CURLOPT_HEADER, TRUE);
}
if($cookie){
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
if($referer){
if($referer==1){
curl_setopt($ch, CURLOPT_REFERER, 'http://m.qzone.com/infocenter?g_f=');
}else{
curl_setopt($ch, CURLOPT_REFERER, $referer);
}
}
if($ua){
curl_setopt($ch, CURLOPT_USERAGENT,$ua);
}else{
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36');
}
if($nobaody){
curl_setopt($ch, CURLOPT_NOBODY,1);
}
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$ret = curl_exec($ch);
curl_close($ch);
//$ret=mb_convert_encoding($ret, "UTF-8", "UTF-8");
return $ret;
}
TAGS
蓝奏云