$return = array();
if('youku.com' == $host) {
//分析视频网址,获取视频编码号
preg_match_all("/id\_(\w+)[\=|.html]/",$link, $matches);
if(!empty($matches[1][0])){
$return['flashvar']= $matches[1][0];
}
//获取视频页面内容,存与$text中
$text=file_get_contents($link);
//获取视频标题
preg_match("/<title>(.*?)-(.*)<\/title>/",
$text, $title);
//获取优酷网上某一视频对应的视频截图,经分析,视频的截图的图片地址在该视频页面html代码里以<liclass="download"></li>标记里的最后一个
http://vimg....
例如
http://vimg20.yoqoo.com/0100641F4649B9D27344B00131FBB6AFDF5175-7D35-930B-E43C-99C59F918E00
preg_match_all("/<liclass="download"(.*)<\/li>/",$text,$match2);
preg_match("/http:\/\/vimg(.*)\|"\>/",$match2[1][0],$imageurl);
if(!empty($imageurl[1])) {
$return['imageurl']= 'http://vimg'.$imageurl[1];
}
if(!empty($title)) {
$return['title']= $title[1];
}
} elseif('ku6.com' == $host) {
//
http://v.ku6.com/show/bjbJKPEex097wVtC.html
//
http://v.ku6.com/special/index_3628020.html
//对于酷6网,末尾以index_开头的地址需要另外分析其视频编码
$text=file_get_contents($link);
preg_match_all("/\/([\w\-]+)\.html/",$link, $matches);
if(1> preg_match("/\/index_([\w\-]+)\.html/", $link)&& !empty($matches[1][0])) {
$return['flashvar']= $matches[1][0];
}else{
preg_match_all("/refer\/(.*)\/v.swf/",$text,$videourl);
$return['flashvar']= $videourl[1][0];
}
preg_match("/<title>(.*?)-(.*)<\/title>/",
$text, $title);
//经分析,酷六的视频截图地址在视频页面的<spanclass="s_pic“></span>标签之间
preg_match_all("/<spanclass="s_pic">(.*)<\/span>/",$text,$imageurl);
if(!empty($imageurl[1][0])) {
$return['imageurl']= $imageurl[1][0];
}
if(!empty($title)) {
$return['title']= $title[1];
}
}elseif ('tudou.com' == $host){
//http://www.tudou.com/programs/view/_ke1lzCnBYw/
$tudou =file_get_contents($link);
preg_match_all("/view\/([\w\-]+)\//",$link, $matches);
if(!empty($matches[1][0])){
$return['flashvar']= $matches[1][0];
}
preg_match("/<title>(.*?)-(.*)<\/title>/",
$tudou, $title);
preg_match_all("/<spanclass="s_pic">(.*)<\/span>/",$tudou,$imageurl);
if(!empty($imageurl[1][0])) {
$return['imageurl']= $imageurl[1][0];
}
if(!empty($title)) {
$return['title']= $title[1];
}
}
return $return;
}