Home > 感悟 > 快手视频无水印下载实现-2020年最新

快手视频无水印下载实现-2020年最新0+

20,516 views / 2020.03.14 / 9:09 下午

上文发了抖音的视频解析脚本后(原文:https://www.71j.cn/archives/493),很多朋友来问快手的有没有。
晚上吃完饭闲着没事,我把快手的安卓端逆向解析了下,发现也没什么难的,关键是有个签名要计算出来。
好,接下来,我们来解析这个地址:https://v.kuaishou.com/s/J87xkobF

$url = "https://v.kuaishou.com/s/J87xkobF";

首先把从apk中提取的几个神秘变量标记出来:

$salt = "382700b563f4";
$client_key = "3c2cd3f3";
$textApi = "http://api.gifshow.com/rest/n/tokenShare/info/byText";

接下来,算签名:

$str = "client_key=3c2cd3f3shareText=".$url.$salt;
$sign = md5($str);

然后获取视频的真实地址:

$data = http_build_query(array("client_key"=>$client_key,"shareText"=>$url,"sig"=>$sign));
    $opts = array(
      'http'=>array(
        'method'=>"POST",
        'header'=>$header. "Content-Length: " . strlen($data) . "\r\n",
        'content'=>$data
      )
    );
    $context = stream_context_create($opts);
    $content = file_get_contents($textApi, false, $context);

搞定。

完整的代码如下:

function kuaishou($url){
    //url: https://v.kuaishou.com/s/J87xkobF
    $salt = "382700b563f4";
    $str = "client_key=3c2cd3f3shareText=".$url.$salt;
    $sign = md5($str);
    $header = "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16D57 Version/12.0 Safari/604.1\r\n";
    $header .="Content-type: application/x-www-form-urlencoded\r\n";
    $data = http_build_query(array("client_key"=>"3c2cd3f3","shareText"=>$url,"sig"=>$sign));
    $opts = array(
      'http'=>array(
        'method'=>"POST",
        'header'=>$header. "Content-Length: " . strlen($data) . "\r\n",
        'content'=>$data
      )
    );
    $context = stream_context_create($opts);
    $content = file_get_contents("http://api.gifshow.com/rest/n/tokenShare/info/byText", false, $context);
    $j1 = json_decode($content, true);
    if($j1['result']!=1) exit("系统分析错误");
    echo $j1['shareTokenDialog']['feed']['main_mv_url'];
}
本站内容受著作权法保护。个人 blog 转载时请遵循 “署名-非商业用途-保持一致” 的创作共用协议;商业网站或未授权媒体不得复制本站内容。

Comments (0) Trackbacks (0) 本篇共有 0 篇评论↓
  1. No comments yet.
  1. No trackbacks yet.