本文執行個體講述了PHP批量擷取網頁中所有固定種子連結的方法。分享給大家供大家參考,具體如下:
經常的下載連結比較多的時候,就像一次性將所有的連結添加到迅雷或者電爐,但是沒有在這種選項,怎麼辦,咱是PHPer啊,這事兒難不到咱
且看代碼,當然要換成你的,要根據具體情況來做修改。
<?phpheader("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數學運算技巧總結》、《phpRegex用法總結》、《PHP運算與運算子用法總結》、《php字串(string)用法總結》及《php常見資料庫操作技巧匯總》
希望本文所述對大家PHP程式設計有所協助。