【原创】某音去水印视频接口源码 (PHP版)
本帖最后由 wushaominkk 于 2019-6-6 20:55 编辑某音去水印视频接口源码 (PHP版)
1、复制分享链接,如:http://v.douyin.com/2CoDUQ
2、传入URL参数 _u ,如:http//localhost/douyin.php?_u=http://v.douyin.com/2CoDUQ
3、直接访问返回数据:
{
"code": 0,
"errMsg": "success",
"videoUrl": "http://v3-dy.ixigua.com/8b4fe1e7b51e4149aed8588b29a81de0/5c94c693/video/m/2200cdd9ab610d84c63854d21774c14e6851161aaade0000341693e2e587/?rc=ajZyeGQ6cHFwbDMzaWkzM0ApQHRAbzZENTQ0OTczNDc6OzU2PDNAKXUpQGczdylAZmxkamV6aGhkZjs0QDQyL3Ffb2BoNl8tLTEtMHNzLW8jbyMyLzU0MC0uLS0tLy4vLS4vaTpiLW8jOmAtbyNtbCtiK2p0OiMvLl4%3D,#此为无水印视频链接
"tmp": 1553250424
}
douyin.php:
header('Content-type: application/json');
$_u = $_GET['_u'];
function _g($_u,$_n=0) {
$_h = curl_init();
curl_setopt($_h, CURLOPT_URL, $_u);
curl_setopt($_h, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($_h, CURLOPT_HEADER, false);
curl_setopt($_h, CURLOPT_HTTPHEADER, array(
'user-agent:Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Mobile Safari/537.36'
));
if($_n==1){
curl_setopt($_h, CURLOPT_NOBODY, 1);
curl_setopt($_h, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($_h);
$_r = curl_getinfo($_h, CURLINFO_EFFECTIVE_URL);
}else{
$_r = curl_exec($_h);
}
curl_close($_h);
return $_r;
}
if(strpos($_u,'com') !== false){
$_u = _g(_g($_u,1));
preg_match('/class=\"video-player\" src=\"(.*?)\" preload/is', $_u, $_m);
$_m = str_replace("line=0","line=1",str_replace("playwm","play",$_m));
$_v = _g($_m,1);
if($_v==''){
$_c = 0701.1;
$_s = 'error';
}else{
$_c = 0;
$_s = 'success';
}
}else{
$_c = 0701.2;
$_s = 'url does not match';
}
echo json_encode(array("code" => $_c, "errMsg" => $_s,"videoUrl" => $_v,"tmp" => time()), JSON_UNESCAPED_SLASHES); 以上代码还要加<?php ?><?php在前 ?>在后 感谢楼主分享,我来给这个配一个简陋的ajax请求前端
<html>
<head>
</head>
<body>
<script>
function href(){
var url = document.getElementById("url").value;
var request = new XMLHttpRequest(); // 新建XMLHttpRequest对象
// 发送请求:
request.open("GET", "douyin.php?_u="+url,true);
request.send();
//请求结果:
request.onreadystatechange = function () { // 状态发生变化时,函数被回调
if (request.readyState === 4) { // 成功完成
// 判断响应结果:
if (request.status === 200) { //解析json并输出
var json = JSON.parse(request.responseText);
document.getElementById("content").innerHTML = json.videoUrl;//打印key为“videoUrl”的值
}
}
}
}
</script>
<!--ajax数据显示div-->
<div id="content"></div>
<form>
<input type="text" id="url">
</form>
<button type="button" onclick="href()">开始解析</button>
</body>
</html>
效果如下
https://imgchr.com/i/Eevr24 这个可以啊,学习了啊!! 感谢楼主分享 确实可以,谢谢楼主 这个好,感谢分享 突然有用py抓取下载视频的想法了{:301_1003:} 厉害了,,我也在研究。。没弄明白。。哈哈。 大象无形 发表于 2019-3-22 21:42
亲测,无用啊
怎么会呢?