微博里很多自媒体视频,各种类型都有,有时看到好视频想要保存,总是通过浏览器开发者工具查看微博视频地址有些麻烦,为了方便蓝叶就写了个微博视频地址解析php代码,只需要把下面蓝叶分享微博视频地址解析php代码复制到新建的php文件里,上传文件到主机里,通过浏览器访问微博视频地址解析php文件,带上微博视频地址参数就可以直接跳转到视频下载地址了,使用鼠标右键即可下载。
<?php //使用方法:weibo.php?url=微博视频地址 error_reporting(0); $domain = trim($_SERVER['SERVER_NAME']); $opendomain = array("127.0.0.1","localhost","lanye.org"); if(in_array($domain, $opendomain)){ $url = isset($_GET['url']) ? addslashes($_GET['url']) : 'https://weibo.com/tv/show/1034:4594989955743747'; $url = str_replace('?from=old_pc_videoshow','',$url); preg_match('/show\/(.*)/i', $url, $matches); $fid = $matches[1]; if(!$fid){die('蓝叶提醒:获取错误,请检测微博视频网址是否正确。');} $content = 'https://video.h5.weibo.cn/s/video/object?object_id='.$fid; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$content); curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0); curl_setopt($ch, CURLOPT_REFERER,$url); curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'); $output = curl_exec($ch);curl_close($ch);$data = json_decode($output,true); if($data['ok']){ $sd_url = str_replace('http','https',$data['data']['object']['stream']['url']); $hd_url = str_replace('http','https',$data['data']['object']['stream']['hd_url']); if($hd_url){ header('location:'.$hd_url);exit(); }else{ header('location:'.$sd_url);exit(); } }else{ die('蓝叶提醒:获取错误,请检测微博视频网址是否正确。'); } }else{ die('蓝叶提醒:请勿盗链。'); }
百度音乐视频播放器
免责声明:
本页网址:点击复制分享给朋友吧!
本站分享的一切内容资源如若没有备注,均为蓝叶原创,如需转载请注明出处;如有侵权请与我们联系处理。敬请谅解!