<?php
//使用方法 域名/dy.php?url=https://v.douyin.com/TudRFh/
error_reporting( E_ALL&~E_NOTICE );
$url = $_GET['url'];
$res = http_get($url);
preg_match('/href="(.*?)">Found/', $res, $matches);
$temp=str_replace('&', '&', $matches[1]);
preg_match('/(?<=video\/).*(?=\/\?region)/', $temp, $matches);
$arr = json_decode(http_get('https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids='. $matches[0]), true);
preg_match('/href="(.*?)">Found/', http_get(str_replace('playwm', 'play', $arr['item_list'][0]["video"]["play_addr"]["url_list"][0])), $matches);
$videoUrl = str_replace('&', '&', $matches[1]);
echo $videoUrl;
function http_get($url)
{
$Header=array( "User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1");
$con=curl_init((string)$url);
curl_setopt($con,CURLOPT_HEADER,False);
curl_setopt($con,CURLOPT_SSL_VERIFYPEER,False);
curl_setopt($con,CURLOPT_RETURNTRANSFER,true);
curl_setopt($con,CURLOPT_HTTPHEADER,$Header);
curl_setopt($con,CURLOPT_TIMEOUT,5000);
$result = curl_exec($con);
return $result;
}
?>
2
<?php
header("Content-Type: text/html;charset=utf-8");
if(isset($_GET["url"])){
//設(shè)置移動(dòng)端請(qǐng)求頭
$hdrs = array(
'http' =>array('header' =>
"Referer: [url=https://v.douyin.com/]https://v.douyin.com/[/url]" .
"User-Agent: Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Mobile Safari/537.36\r\n"
),
);
//設(shè)置請(qǐng)求頭
$context = stream_context_create($hdrs);
//通過(guò)請(qǐng)求獲得該視頻的id
file_get_contents($_GET["url"],0,$context);
$id=$http_response_header[6];
$id=explode("video/",$id);
$id=explode("/?",$id[1]);
$id=$id[0];
//通過(guò)接口獲得視頻的詳細(xì)內(nèi)容
$url="https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=".$id;
$jsonData=file_get_contents($url,0,$context);
$jsonData=json_decode($jsonData);
//獲取到視頻有水印的播放地址
$url=$jsonData->item_list[0]->video->play_addr->url_list[0];
//獲取到視頻無(wú)水印的播放地址
$url=str_replace("playwm","play",$url);
//獲取真實(shí)的視頻url
file_get_contents($url,0,$context);
for($i=0;$i<sizeof($http_response_header);$i++){
$url=$http_response_header[$i];
if(substr($url,0,8)=="location"){
$url=$http_response_header[$i];
break;
}
}
$url=str_replace("location: ","",$url);
echo $url;
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。