Home > Article > Backend Development > How to get all fixed seed links in a web page in batches with PHP
The example in this article describes the method of obtaining all fixed seed links in a web page in batches with PHP. Share it with everyone for your reference, the details are as follows:
When there are often a lot of download links, it is like adding all the links to Thunder or Electric Stove at once, but there is no such option. What should I do? We are PHPer. This is not difficult for us
Let’s look at the code. Of course, it needs to be replaced with yours, and modifications must be made according to the specific situation.
<?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; } ?>