用PHP获取土豆网视频FLV地址
生活随笔
收集整理的這篇文章主要介紹了
用PHP获取土豆网视频FLV地址
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
主要代碼:<?php???
//?根據視頻地址取內容???
$url?=?"http://www.tudou.com/programs/view/B6q-LhN9e-0/";???
$txt?=?file_get_contents($url);???
??
//?取視頻ID???
preg_match("/var?iid?=?(\d+)/",?$txt,?$match_id);???
preg_match("/<title>(.*?)?-?.*<\/title>/",?$txt?,?$match_title);???
$id?=?$match_id[1];???
$title?=?$match_title[1];???
??
//?取視頻的絕對地址???
$url?=?"http://v2.tudou.com/v2/cdn?id={$id}&safekey=YouNeverKnowThat&noCatch=4610";???
$context?=?array(???
????'http'?=>?array?(???
????????'header'=>?'User-Agent:?'?.?$_SERVER['HTTP_USER_AGENT']???
????)???
);???
$xcontext?=?stream_context_create($context);???
$txt?=?file_get_contents($url,?false,?$xcontext);???
??
preg_match_all("/<f.*?>(.*?)<\/f>/",?$txt,?$match);???
if?(is_array($match[1]))???
{???
????foreach?($match[1]?as?$k?=>?$v)???
????{???
????????$c?=?$k?+?1;???
????????echo?"下載地址{$c}:<a?href=\"$v\">{$title}?($v)</a>??<br?/>\n";???
????}???
}???
?> ?
//?根據視頻地址取內容???
$url?=?"http://www.tudou.com/programs/view/B6q-LhN9e-0/";???
$txt?=?file_get_contents($url);???
??
//?取視頻ID???
preg_match("/var?iid?=?(\d+)/",?$txt,?$match_id);???
preg_match("/<title>(.*?)?-?.*<\/title>/",?$txt?,?$match_title);???
$id?=?$match_id[1];???
$title?=?$match_title[1];???
??
//?取視頻的絕對地址???
$url?=?"http://v2.tudou.com/v2/cdn?id={$id}&safekey=YouNeverKnowThat&noCatch=4610";???
$context?=?array(???
????'http'?=>?array?(???
????????'header'=>?'User-Agent:?'?.?$_SERVER['HTTP_USER_AGENT']???
????)???
);???
$xcontext?=?stream_context_create($context);???
$txt?=?file_get_contents($url,?false,?$xcontext);???
??
preg_match_all("/<f.*?>(.*?)<\/f>/",?$txt,?$match);???
if?(is_array($match[1]))???
{???
????foreach?($match[1]?as?$k?=>?$v)???
????{???
????????$c?=?$k?+?1;???
????????echo?"下載地址{$c}:<a?href=\"$v\">{$title}?($v)</a>??<br?/>\n";???
????}???
}???
?> ?
轉載于:https://www.cnblogs.com/relax/archive/2011/10/26/2225224.html
總結
以上是生活随笔為你收集整理的用PHP获取土豆网视频FLV地址的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 谁说菜鸟不会数据分析--数据分析那些事儿
- 下一篇: php冒泡排序和快速排序笔记