日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

PHP获取优酷视频FLV地址

發布時間:2024/1/17 php 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PHP获取优酷视频FLV地址 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在使用Ckplayer播放視頻的時候,因為要讀取第三方網站的視頻數據,這里就需要獲取如優酷的FLV地址,則將下面的內容存儲為 yk.php,并通過 yk.php?u=url(優酷的視頻播放地址) 獲取真實地址 <?php @header("Content-Type: text/html; charset=gb2312");if(isset($_GET['u'])) $url = safeurl($_GET['u']); (empty($url)) && exit(); $f = isset($_GET['f']) ? (!preg_match("/^[0-9]+$/",$_GET['f']) ? 0 : intval($_GET['f'])) : 0; $f = 2; //默認為超清. if($f == 1) { $f = 'high'; } else if($f == 2) { $f = 'super'; } else if($f == 5) { $f = 'super2'; } else if($f == 9) { $f = 'real'; } else { $f = 'normal'; } $url=str_replace(']','/',$url); $url=str_replace('[','.',$url); $url=str_replace('##','?',$url); $url=str_replace('{','&',$url); //$page = getsite('http://www.flvcd.com/parse.php?kw='.$url.'&flag=one&format='.$f); $page = getsite('http://www.flvcd.com/parse.php?kw='.$url.'&flag=&format='); $video = getbody($page,'<strong>當前解析視頻','<br>花費時間',1); //echo $video; $videos = explode('</a>',$video); $video = ''; for($i=0;$i<count($videos);++$i){ $tmp = getbody($videos[$i],'href="','"',1); if(!empty($tmp)) { $i > 0 && $video .= '|'; $video .= $tmp; } } $video=str_replace('&amp;','&',$video); //$video=str_replace('&amp;','[]',$video); //$video=str_replace('&','[]',$video); echo $video; exit(); //(!empty($video)) && @header("location:".$video);function getsite($url){ $buf=parse_url($url); if($buf["scheme"]=="http"){ $host=$buf["host"]; $page=$buf["path"]; if(trim($buf["query"])!=="") $page.="?".trim($buf["query"]); $myHeader="GET ".$url." HTTP/1.1\r\n"; $myHeader.="Host:".$host."\r\n"; $myHeader.="Connection:close\r\n"; $myHeader.="Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n"; $myHeader.="Accept-Language:zh-cn,zh;q=0.5\r\n"; $myHeader.="Accept-Charset:gb2312,utf-8;q=0.7,*;q=0.7\r\n"; $myHeader.="User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:5.0.1) Gecko/20100101 Firefox/5.0.1 Web-Sniffer/1.0.20\r\n"; $myHeader.="Referer: http://".$host."/\r\n\r\n"; $server=$host; $port=80; $res=""; if(false!==($fp = @fsockopen($server,$port,$errno,$errstr,30))){ @fputs ($fp, $myHeader); while (!@feof($fp)) $res.= @fgets($fp,1024); @fclose ($fp); }else{ return false; } if(strlen($res)==0) return false; return $res; }else{ $fileName=$url; if(false!==@file_exists($fileName)){ if(false!==($buf=@implode("",file($fileName)))&&@strlen($buf)>0){ return $buf; }else{ return false; } }else{ return false; } } } function getbody($s,$ss,$se,$sn){ $arr = explode($ss,$s); @$t=$arr[1]; if(empty($t)) return ''; if(empty($se)){ return $t; }else{ $arr=explode($se,$t); if($sn==1){ return $arr[0]; }elseif($sn==2){ return $ss.$arr[0]; }elseif($sn==3){ return $arr[0].$se; }else{ return $ss.$arr[0].$se; } } } function safeurl($s) { $s = str_replace('%20','',$s); $s = str_replace('%27','',$s); $s = str_replace('%2527','',$s); $s = str_replace('*','',$s); $s = str_replace('"','&quot;',$s); $s = str_replace("'",'',$s); $s = str_replace('"','',$s); $s = str_replace(';','',$s); $s = str_replace('<','&lt;',$s); $s = str_replace('>','&gt;',$s); $s = str_replace("{",'',$s); $s = str_replace('}','',$s); $s = str_replace('\\','',$s); return trim($s); } ?>

總結

以上是生活随笔為你收集整理的PHP获取优酷视频FLV地址的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。