抖音小视频无水印地址解析源码分享

0508更新:官方接口https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=itemId值&dytk=dytk值
file_get_contents抓取数据,然后输出json格式

<?php
error_reporting(0); 
$act=isset($_GET['act'])?$_GET['act']:null;
$url=isset($_GET['url'])?$_GET['url']:null;
    switch($act){
        case 'dy':
            $reurl = substr($url,strpos($url,"http"));
            if(strpos($reurl," ")>0){
                $reurl = substr($reurl,0,strpos($reurl," "));
            }
            ini_set('user_agent','user-agent: Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3');
            $url = file_get_contents($reurl);

            preg_match('/itemId:\s+\"(.*?)\"/sS',$url,$itemId);
            preg_match('/dytk:\s+\"(.*?)\"/sS',$url,$dytk);
            $json = file_get_contents('https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids='.$itemId[1].'&dytk='.$dytk[1]);
            $res = json_decode($json,true);

            $name = $res['item_list'][0]['desc'];//名称
            $img = $res['item_list'][0]['video']['origin_cover']['url_list'][0];//图
            $img_run = $res['item_list'][0]['video']['dynamic_cover']['url_list'][0];//缩略视频
            $zan = $res['item_list'][0]['statistics']['digg_count']; //点赞
            $pl = $res['item_list'][0]['statistics']['comment_count']; //评论
            $url = $res['item_list'][0]['video']['play_addr']['url_list'][0];
            $video = getrealurl(str_replace("playwm","play",$url));
            if(!empty($url)){
                echo '{"code":1,"msg":"解析成功","name":"'.$name.'","url":"'.$video.'","img":"'.$img.'","img_run":"'.$img_run.'","zan":"'.$zan.'","pl":"'.$pl.'"}';
            }else{
                echo '{"code":-1,"msg":"未知错误"}';
            }
        break;
    default:
        exit('{"code":0,"msg":"No Act"}');
    break;
}

        function getrealurl($url){
            $header = get_headers($url,1);
            return $header['location']; 
        }   
 ?>

以前分享过抖音无水印解析的代码但是好像失效了,这里在分享一个新的解析代码,不过是带水印的,以后有时间在研究下去水印的解析代码。

抖音短视频无水印解析接口源码

<?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('/<p class="desc">(?<desc>[^<>]*)<\/p>/i', $data, $name);
preg_match('/playAddr: "(?<url>[^"]+)"/i', $data, $url);
if (empty($url['url'])) {
echo '没有地址参数';
}else{
$array = ['name' => $name['desc'],'url' => $url['url'],];
$json = json_encode($array,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);
echo $json;
}
?>

9/12今天抽空搞了下,更新无水印解析代码,防止被封太快,象征信收取点费用。


给TA买糖
共{{data.count}}人
人已赞赏
源码分享

网易云音乐下载地址解析

2019-5-11 20:25:15

源码分享

搜狗图床文件上传接口源码

2019-9-9 16:40:32

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
有新私信 私信列表
搜索