+ -
当前位置:首页 → 问答吧 → [原创]PHP解析 酷6视频 mp4真实地址

[原创]PHP解析 酷6视频 mp4真实地址

时间:2009-08-17

来源:互联网

续 [PHP解析土豆FLV真实地址] 后 再发布 PHP解析 酷6视频 mp4真实地址代码
支持以下两种格式
http://v.ku6.com/show/kyaZJccsLKAsgyVw.html
http://hd.ku6.com/show/m0OTTkGVDwbwSk6w.html
演示地址:http://cheon.info/ku6.php
从78行到112行是 unicode转utf-8的函数
支持js unicode(例:\u6d77)和html unicode(例:#31461;)的转换<?php
/*
* CheonNii(泉泉)
* http://cheon.info
*/
function curl_get_contents($url)
{
if(!function_exists('curl_init')) {
return false;
} else {
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
$content = curl_exec($ch);
$errormsg = curl_error($ch);
curl_close($ch);
if($errormsg != '') {
echo $errormsg;
return false;
}
return $content;
}
}

function fsock_get_contents($url)
{
if(!function_exists('fsockopen')) {
return false;
} else {
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$url = eregi_replace('^http://', '', $url);
$temp = explode('/', $url);
$host = array_shift($temp);
$path = '/'.implode('/', $temp);
$temp = explode(':', $host);
$host = $temp[0];
$port = isset($temp[1]) ? $temp[1] : 80;
$fp = @fsockopen($host, $port, $errno, $errstr, 30);
if ($fp){
@fputs($fp, \"GET $path HTTP/1.1\r\nHost: $host\r\nAccept: */*\r\nRefererurl\r\nUser-Agent: $user_agent\r\nConnection: Close\r\n\r\n\");
}
$content = '';
while ($str = @fread($fp, 4096)){
$content .= $str;
}
@fclose($fp);
//Redirect
if(preg_match(\"/^HTTP\/\d.\d 301 Moved Permanently/is\", $content)){
if(preg_match(\"/Location.*?)\r\n/is\", $content, $murl)){
return fsock_get_contents($murl[1]);
}
}
//Read contents
if(preg_match(\"/^HTTP\/\d.\d 200 OK/is\", $content)){
preg_match(\"/Content-Type.*?)\r\n/is\", $content, $murl);
$contentType = trim($murl[1]);
$content = explode(\"\r\n\r\n\", $content, 2);
$content = $content[1];
}
return $content;
}
}

function get_page_contents($url)
{
$content = '';
if(function_exists('curl_init')) {
$content = curl_get_contents($url);
} elseif (function_exists('fsockopen')) {
$content = curl_get_contents($url);
} else echo \"函数 curl_init 和 fsockopen 都为关闭,请至少打开一个.\";
return $content;
}

function uni_decode($s) {
preg_match_all('/\&\#([0-9]{5})\;/', $s, $html_uni);
preg_match_all('/\\\u([0-9a-f]{4})/ie', $s, $js_uni);
$source = array_merge($html_uni[0], $js_uni[0]);
$js = array();
for($i=0;$i<count($js_uni[1]);$i++) {
$js[] = hexdec($js_uni[1][$i]);
}
$utf8 = array_merge($html_uni[1], $js);
$code = $s;
for($j=0;$j<count($utf8);$j++) {
$code = str_replace($source[$j], unicode2utf8($utf8[$j]), $code);
}
return $code;//$s;//preg_replace('/\\\u([0-9a-f]{4})/ie', \"chr(hexdec('\\1'))\", $s);
}

function unicode2utf8($c) {
$str=\"\";
if ($c < 0x80) {
$str.=chr($c);
} else if ($c < 0x800) {
$str.=chr(0xc0 | $c>>6);
$str.=chr(0x80 | $c & 0x3f);
} else if ($c < 0x10000) {
$str.=chr(0xe0 | $c>>12);
$str.=chr(0x80 | $c>>6 & 0x3f);
$str.=chr(0x80 | $c & 0x3f);
} else if ($c < 0x200000) {
$str.=chr(0xf0 | $c>>18);
$str.=chr(0x80 | $c>>12 & 0x3f);
$str.=chr(0x80 | $c>>6 & 0x3f);
$str.=chr(0x80 | $c & 0x3f);
}
return $str;
}

function get_mp4($url)
{
$mp4_info = array();
$video_data = get_page_contents($url);

preg_match('/title: \\"(.*?)\\"/', $video_data, $match_title);
preg_match('/\\"f\\"\:\\"(.*?)\\"/', $video_data, $match_file);
$mp4_info['title'] = uni_decode($match_title[1]);
$mp4_info['file'] = uni_decode($match_file[1]);
return $mp4_info;
}
?>
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
<title>HP解析酷6视频mp4真实地址</title>
</head>

<body>
支持以下两种格式<br />
<a href=\"javascript://\" onclick=\"document.getElementById('url').value = this.title;\" title=\"http://v.ku6.com/show/kyaZJccsLKAsgyVw.html\">http://v.ku6.com/show/kyaZJccsLKAsgyVw.html</a><br />
<a href=\"javascript://\" onclick=\"document.getElementById('url').value = this.title;\" title=\"http://hd.ku6.com/show/m0OTTkGVDwbwSk6w.html\">http://hd.ku6.com/show/m0OTTkGVDwbwSk6w.html</a><br />
<form action=\"<?php echo $_SERVER['PHP_SELF']; ?>\" method=\"post\">
<label>URL
<input type=\"text\" name=\"url\" id=\"url\" style=\"width:300px;\" />
</label>
<label>
<input type=\"submit\" name=\"button\" id=\"button\" value=\"解析\" />
</label>
</form>
<div style=\"clear:both;\"></div>
<?php
if($_POST) {
$mp4 = get_mp4($_POST['url']);
echo '视频标题:'.$mp4['title'].'<br />';
$file = explode(',', $mp4['file']);
$s = count($file);
if($s > 1) {
echo '该视频由'.$s.'段组成,下载地址如下:';
} else echo '视频真实地址:';
foreach($file as $v) {
echo \"<br \/><a href=\\"$v\\">$v</a>\";
}
}
?>

</body>
</html>原文地址:http://cheon.info/444

作者: cheonnii   发布时间: 2009-08-17

真是不错哦

作者: 阿伍   发布时间: 2009-08-17

比较厉害哦

作者: liu12358   发布时间: 2009-08-17

以后去偷视频就容易了

作者: 我是疯子   发布时间: 2009-08-17

热门下载

更多