抖音短视频去水印PHP源码

2020年04月28日

转自hostloc论坛
这个是利用抖音官方api接口来去除短视频水印的方法,这里做个记录。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!--?php
//by 勤勤学长
//使用方法 域名/dyapi.php?url=https://v.douyin.com/TudRFh/
$url = $_GET['url'];
$res = qqxz_http_get($url);
preg_match('/href="(.*?)"-->Found/', $res, $matches);
$Xurl = str_replace('&', '&', $matches[1]);
$res = qqxz_http_get($Xurl);
preg_match('/itemId: "(.*?)",/', $res, $matches);
$itemId = $matches[1];
$url = 'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=' . $itemId;
$res = qqxz_http_get($url);
$arr = json_decode($res, true);//作品信息获取
$play_addr_url = $arr['item_list'][0]["video"]["play_addr"]["url_list"][0];
$res = qqxz_http_get($play_addr_url);
preg_match('/href="(.*?)">Found/', $res, $matches);
$videoUrl = str_replace('&', '&', $matches[1]);
$douyin = ['code' => 1, 'url' => $videoUrl];
echo json_encode($douyin);
function qqxz_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;
}
?>
<!--?php //by 勤勤学长 //使用方法 域名/dyapi.php?url=https://v.douyin.com/TudRFh/ $url = $_GET['url']; $res = qqxz_http_get($url); preg_match('/href="(.*?)"-->Found/', $res, $matches); $Xurl = str_replace('&', '&', $matches[1]); $res = qqxz_http_get($Xurl); preg_match('/itemId: "(.*?)",/', $res, $matches); $itemId = $matches[1]; $url = 'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=' . $itemId; $res = qqxz_http_get($url); $arr = json_decode($res, true);//作品信息获取 $play_addr_url = $arr['item_list'][0]["video"]["play_addr"]["url_list"][0]; $res = qqxz_http_get($play_addr_url); preg_match('/href="(.*?)">Found/', $res, $matches); $videoUrl = str_replace('&', '&', $matches[1]); $douyin = ['code' => 1, 'url' => $videoUrl]; echo json_encode($douyin); function qqxz_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; } ?>
    Found/', $res, $matches);
            $Xurl = str_replace('&', '&', $matches[1]);
            $res = qqxz_http_get($Xurl);
            preg_match('/itemId: "(.*?)",/', $res, $matches);
            $itemId = $matches[1];
            $url = 'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=' . $itemId;
            $res = qqxz_http_get($url);
            $arr = json_decode($res, true);//作品信息获取
            $play_addr_url = $arr['item_list'][0]["video"]["play_addr"]["url_list"][0];
            $res = qqxz_http_get($play_addr_url);
            preg_match('/href="(.*?)">Found/', $res, $matches);
            $videoUrl = str_replace('&', '&', $matches[1]);
            $douyin = ['code' => 1, 'url' => $videoUrl];
            echo json_encode($douyin);

           function qqxz_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;
    }
    ?>

 


sicnature ---------------------------------------------------------------------
I P 地 址: 3.142.220.14
区 域 位 置: 美国
系 统 信 息: 美国
Original content, please indicate the source:
同福客栈论坛 | 蟒蛇科普海南乡情论坛 | JiaYu Blog
sicnature ---------------------------------------------------------------------
Welcome to reprint. Please indicate the source https://myzhenai.com/post/3286.html

1 评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注