虎牙视频站里多数是游戏解说、游戏攻略等视频,对于做游戏视频资源的网站可以从虎牙视频站里调用视频,下面分享虎牙视频PHP解析调用代码,把代码复制一个php文件里,保存后上传到主机空间里调用。vxt天浩博客
调用说明:例如http://v.huya.com/play/2865447.html这个播放页的ID为2865447,使用PHP解析调用方法为http://你的域名/huya.php?id=2865447,如果主机不支持curl扩展是无法使用此代码的,请低调使用。vxt天浩博客
vxt天浩博客
error_reporting(0);vxt天浩博客
$videoid = isset($_GET['id']) ? addslashes(trim($_GET['id'])) : '';vxt天浩博客
if(!empty($videoid)){vxt天浩博客
$url = 'http://m.v.huya.com/play/'.$videoid.'.html';vxt天浩博客
$refer = 'http://m.v.huya.com/play/'.$videoid.'.html';vxt天浩博客
$ch = curl_init();vxt天浩博客
curl_setopt($ch, CURLOPT_URL, $url);vxt天浩博客
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);vxt天浩博客
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);vxt天浩博客
curl_setopt($ch, CURLOPT_REFERER, $refer);vxt天浩博客
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30');vxt天浩博客
$output = curl_exec($ch);vxt天浩博客
curl_close($ch);vxt天浩博客
preg_match('|video src="(.*?)"|i', $output, $endput);vxt天浩博客
$videourl = $endput[1];vxt天浩博客
header("Location:".$videourl);vxt天浩博客
}else{echo '视频ID错误,请输入视频ID号码';}vxt天浩博客
?>vxt天浩博客
vxt天浩博客
转载:感谢您对天浩博客网站平台的认可,以及对我们原创作品和文章的青睐,非常欢迎各位朋友分享到个人站长或者朋友圈,但转载请说明文章出处“来源天浩博客”。https://www.tianhao.cc/study/web/146.html