php坐网页视频,PHP解析网页视频

/*解析视频*/

function parse_vedio($vedio_url = '') {

$url = empty ( $vedio_url ) ? $_GET ['vedio_url'] : $vedio_url;

$data = array ();

$temp_data = array ();

$pic_url = '';

$result = array ();

if (preg_match ( '/http:\/\/v.youku.com\/v_show.*id_(.*)\.html/U', $url, $data )) {

if (! empty ( $data )) {

$result ['real_url'] = ' http://player.youku.com/player.php/sid/' . $data [1] . '/v.swf';

$result ['company'] = '优酷';

$temp_data = file_get_contents ( $url );

preg_match ( '/pic=(.*)" target="_blank"/U', $temp_data, $pic_url );

if (! empty ( $pic_url )) {

$result ['pic_url'] = $pic_url [1];

}

}

} elseif (preg_match ( '/http:\/\/www.tudou.com\/(.).*\/(.*)\.html/U', $url, $data )) {

$new_data = explode ( '/', $data [2] );

$temp = array ();

$html = file_get_contents ( $url );

preg_match ( '/.*iid:\s?(\d+)[\s\S]*pic:\s?"(.*)"/', $html, $temp );

if (! empty ( $data ) && ! empty ( $temp )) {

$result ['real_url'] = 'http://www.tudou.com/' . $data [1] . '/' . $new_data [0] . '/&iid=' . $temp [1] . '/v.swf';

$result ['company'] = '土豆';

$result ['pic_url'] = $temp [2];

}

} elseif (preg_match ( '/http:\/\/(.*)tv.sohu.com\/.*\/(.*.shtml|.*\/(.*))/', $url, $temp_data )) {

$html = file_get_contents ( $url );

if (empty ( $temp_data [1] )) {

$temp = array ();

$temp_1 = array ();

preg_match ( '/[\s\S]*vid="(\d+)"[\s\S]*var cover="(.*)"/U', $html, $temp );

preg_match ( '/[\s\S]*PLAYLIST_ID="(\d+)"[\s\S]*/', $html, $temp_1 );

$result ['pic_url'] = $temp [2];

if (! empty ( $temp )) {

if (empty ( $temp_1 )) {

$result ['real_url'] = 'http://share.vrs.sohu.com/' . $temp [1] . '/v.swf&autoplay=true&api_key=664cbe6f3376306fa6b3082c770989d0';

} else {

$result ['real_url'] = 'http://share.vrs.sohu.com/' . $temp [1] . '/v.swf&autoplay=true&api_key=664cbe6f3376306fa6b3082c770989d0&plid=' . $temp [1];

}

$result ['company'] = '搜狐';

}

} else {

preg_match ( '/bCover: \'(.*)\'/U', $html, $temp );

$result ['pic_url'] = $temp [1];

$result ['real_url'] = 'http://share.vrs.sohu.com/' . rtrim ( $temp_data [1], '.' ) . '/v.swf&id=' . $temp_data [3] . '&topBar=1&autoplay=true&api_key=664cbe6f3376306fa6b3082c770989d0';

$result ['company'] = '搜狐';

}

} elseif (preg_match ( '/http:\/\/v.ifeng.com\/.*.shtml/U', $url )) {

preg_match ( '/http:\/\/v.ifeng.com\/.*\/((.*\/.*)|(.*))\/(.*).shtml$/U', $url, $data );

$html = file_get_contents ( $url );

if (! empty ( $data )) {

preg_match ( '/"url": "' . addcslashes ( $url, '/' ) . '","img": "(.*)"/', $html, $temp );

$result ['pic_url'] = $temp [1];

$result ['real_url'] = 'http://v.ifeng.com/include/exterior.swf?guid=' . $data [4] . '&AutoPlay=true';

$result ['company'] = '凤凰';

} elseif (preg_match ( '/http:\/\/v.ifeng.com\/.*\/.*\/.*.shtml#(.*)/', $url, $data )) {

preg_match ( '/

[\s\S]* (.*)

$result ['pic_url'] = $temp [1];

$result ['real_url'] = 'http://v.ifeng.com/include/exterior.swf?guid=' . $data [1] . '&AutoPlay=true';

$result ['company'] = '凤凰';

}

} elseif (preg_match ( '/http:\/\/video.sina.com.cn.*/', $url )) {

$flag = true;

$html = file_get_contents ( $url );

preg_match ( '/pic: \'(.*)\'[\s\S]*swfOutsideUrl:\'(.*)\'/U', $html, $data );

if (! empty ( $data )) {

$result ['pic_url'] = $data [1];

$result ['real_url'] = $data [2];

$result ['company'] = '新浪';

}

} elseif (preg_match ( '/http:\/\/(www|yule).iqiyi.com\/(.*).html/', $url, $data )) {

if (! empty ( $data )) {

$html = file_get_contents ( $url );

preg_match ( '/"pid":"(.*)","ptype":"(.*)".*"videoId":"(.*)","albumId":"(.*)".*"tvId":"(.*)".*"qitanId":(.*),[\s\S]*(.*)/U', $html, $temp_data );

if (! empty ( $temp_data )) {

$result ['company'] = '爱奇艺';

$result ['pic_url'] = str_replace ( '_baidu', '', trim ($temp_data [7] ) );

$result ['real_url'] = 'http://player.video.qiyi.com/' . $temp_data [3] . '/0/0/' . ($data [1] == 'www' ? $data [2] : $data [1] . '/' . $data [2]) . '.swf-pid=' . $temp_data [1] . '-ptype=' . $temp_data [2] . '-albumId=' . $temp_data [4] . '-tvId=' . $temp_data [5] . '-autoplay=1-qitanId=' . $temp_data [6] . '-isDrm=0-isPurchase=0';

}

}

} elseif (preg_match ( '/http:\/\/v.163.com\/.*/', $url, $data )) {

if (! empty ( $data )) {

$html = file_get_contents ( $url );

preg_match ( '/name="movie">[\s\S]*moviePicture=\'(.*)\'/U', $html, $data );

if (! empty ( $data )) {

$result ['company'] = '网易';

$result ['real_url'] = 'http://swf.ws.126.net/v/ljk/shareplayer/ShareFlvPlayer.swf?' . $data [1];

$result ['pic_url'] = $data [2];

}

}

}

return $result;

}

$result返回值说明

company : 网站名

real_url : 视频地址

pic_url : 缩略图地址

播放视频HTML代码:

height="356"

allowscriptaccess="never"

style="visibility: visible;"

pluginspage="http://get.adobe.com/cn/flashplayer/"

flashvars="playMovie=true&auto=1"

width="440"

allowfullscreen="true"

quality="high"

src="视频地址"

type="application/x-shockwave-flash"

wmode="transparent">

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值