抖音无水印

<?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"])){
        //设置移动端请求头
        $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"
            ),
        );
        //设置请求头
        $context = stream_context_create($hdrs);
        //通过请求获得该视频的id
        file_get_contents($_GET["url"],0,$context);
        $id=$http_response_header[6];
        $id=explode("video/",$id);
        $id=explode("/?",$id[1]);
        $id=$id[0];
        //通过接口获得视频的详细内容
        $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];
        //获取到视频无水印的播放地址
        $url=str_replace("playwm","play",$url);
        //获取真实的视频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;
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容