通過(guò)正則表達(dá)式獲取百度網(wǎng)盤(pán)的文件真實(shí)地址,來(lái)實(shí)現(xiàn)直鏈的效果,適合一些使用外鏈的網(wǎng)站使用。
<?php $canshu=$_SERVER["QUERY_STRING"]; if($canshu=="") { die("文件不存在"); } else { $wangzhi="http://pan.baidu.com/share/link?".$canshu; $file=file_get_contents($wangzhi); $pattern='/a><a class="dbtn cancel singledbtn" href=(.*?)id="downFileButtom">/i'; preg_match_all($pattern,$file,$result); $tempurl=implode("",$result[1]); $fileurlt=str_replace(""","",$tempurl); $fileurl=str_replace("&","&",$fileurlt); header("location:$fileurl"); } ?>
如效果:
新聞熱點(diǎn)
疑難解答