天天看點

bilibil網站采集 傳回視訊下載下傳位址【代碼】

<?php
    /** 
     * 視訊采集分析視訊相關下載下傳位址
     * $url bilibili動畫視訊url位址 
     * $http_com 位址相關資訊參數
     *  $url 傳回一個檔案下載下傳位址
     */
include 'phpquery/phpQuery/phpQuery.php';//引入phpquery
$url=isset($_GET['url'])?$_GET['url']:'';//擷取url連接配接
$http_com=substr($url,24);//擷取域名位址後面資料
$http=substr($url,0,7);//擷取域名位址後面資料
if($http!='http://'){
    echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
    echo '對不起,位址有誤,請填寫真正确的url位址,或在www.前加入http://,本程式隻支援bilibili動畫的視訊采集';
    exit;
}else{
    echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
}
$url='http://www.ibilibili.com/'.$http_com;
// echo $url;
phpQuery::newDocumentFile($url); 
$companies = pq('#firstLi p')->html();  
// $companies = pq('#firstLi p a')->attr("href");  
// echo($companies);

// $companies = pq('#firstLi a')->html();  
// $companies = pq('#firstLi a')->find('a');  
// foreach($companies as $company)  
// {  
//    echo pq($company)->find('a')->attr("href");  
// }  
$url_list=explode("a href",$companies);
$http=substr($url_list[3],2);//擷取域名位址後面資料
// echo $http;
$url_list=explode('"',$http);
// echo $http[0];
echo ($url_list[0]);

?>