本文由 DTcms素材网 – DT素材网 发布,转载请注明出处,如有问题请联系我们!PHP实现抖音无水印视频解析
收藏
使用方法: 在php后加上 ?url= 抖音的url 跳出来的网页一个是标题 一个是视频无水印的链接。 下面贴出代码。 <?php header("Content-Type: text/json;charset=utf-8"); $url=$_GET["url"]; $UserAgent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022; .NET CLR 1.0.3705; .NET CLR 1.1.4322)'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_ENCODING, ''); curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); $data = curl_exec($curl); curl_close($curl); //获取 preg_match_all('#playwm\/\?video_id=(.?)&line=0#' , $data ,$url); preg_match_all('#<p class="desc">(.?)<\/p>#' , $data ,$name); //正则匹配 if (empty($url[1][0])) { echo '请输入正确网址,格式为:https://xxx.com/douyin.php?url=视频地址'; }else{ $array = ['name' => $name[1][0],'url' => 'https://aweme.snssdk.com/aweme/v1/play/?video_id='.$url[1][0],]; $json = json_encode($array,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT); echo $json; } ?> |