本文實例講述了PHP批量獲取網頁中所有固定種子鏈接的方法。分享給大家供大家參考,具體如下:
經常的下載鏈接比較多的時候,就像一次性將所有的鏈接添加到迅雷或者電爐,但是沒有在這種選項,怎麼辦,咱是PHPer啊,這事兒難不到咱
且看代碼,當然要換成你的,要根據具體情況來做修改。
<?php
header("content-type:text/html;charset=utf8");
$str = file_get_contents('./ShowFile.asp');
$str1 = '<a href="ed2k';
$str2 = '">';
$pos1 = 0;
$pos2 = 0;
$pos3 = 0;
$len = strlen($str);
$ed2k = '';
for($i=5000;$i<$len; ){
$pos1 = strpos($str,$str1,$i) + 9;
$pos2 = strpos($str,$str2,$pos1) - 2;
$pos3 = $pos2 - $pos1;
//說明特征連接已經不存在 放棄尋找
if($pos1 == 9){break;}
$ed2k = substr($str,$pos1,$pos3+1)."\r\n";
file_put_contents('d:/log/a.txt',$ed2k,FILE_APPEND);
echo substr($str,$pos1,$pos3+1).'<hr/>';
$i = $pos2;
}
?>
更多關於PHP相關內容感興趣的讀者可查看本站專題:《php curl用法總結》、《PHP數組(Array)操作技巧大全》、《php排序算法總結》、《PHP常用遍歷算法與技巧總結》、《PHP數據結構與算法教程》、《php程序設計算法總結》、《PHP數學運算技巧總結》、《php正則表達式用法總結》、《PHP運算與運算符用法總結》、《php字符串(string)用法總結》及《php常見數據庫操作技巧匯總》
希望本文所述對大家PHP程序設計有所幫助。