好看视频百度旗下视频站,有很多好听的音乐、好看的短视频,有时看到喜欢的视频想下载收藏,使用浏览器开发者工具可以嗅探到视频地址但操作起来有些麻烦,于是小编就写了个php正则解析好看视频地址代码,复制小编分享的好看视频地址解析php代码到php文件里,浏览器访问传递好看视频页面网址就会自动解析跳转到视频最终地址。
<?php error_reporting(0); header('Content-Type:text/html; charset=utf-8'); date_default_timezone_set('Asia/Shanghai'); $domain = trim($_SERVER['SERVER_NAME']); $opendomain = array("127.0.0.1","localhost","lanyes.org"); $diymusic = 'http://tts.baidu.com/text2audio?idx=1&tex=%E8%AF%B7%E5%8B%BF%E7%9B%97%E9%93%BE%E6%AD%A4api%E6%96%87%E4%BB%B6%E3%80%82&cuid=baidu_speech_demo&cod=2&lan=zh&ctp=1&pdt=1&spd=4&vol=5&pit=5&per=4'; if(in_array($domain, $opendomain)){ $url = isset($_GET['url']) ? addslashes($_GET['url']) : 'https://haokan.baidu.com/v?vid=7944510417347427713'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_REFERER, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($curl); curl_close($curl); preg_match('/,"clarityUrl":(.*?),"video_status":(.*?),/i',$response,$matchs);//www.8gws.com $jsondat = json_decode($matchs[1],true); $jsoncount = count($jsondat); if($jsoncount==3 || $jsoncount==4){ $videourl = $jsondat[2]['url']; }elseif($jsoncount==2){ $videourl = $jsondat[1]['url']; }else{ $videourl = $jsondat[0]['url']; } header("location: $videourl");exit; }else{header('Location:'.$diymusic);exit();} ?>