Home  >  Article  >  Backend Development  >  How to get all fixed seed links in a web page in batches with PHP

How to get all fixed seed links in a web page in batches with PHP

高洛峰
高洛峰Original
2016-12-12 10:06:541725browse

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(&#39;./ShowFile.asp&#39;);
$str1 = &#39;<a href="ed2k&#39;;
$str2 = &#39;">&#39;;
$pos1 = 0;
$pos2 = 0;
$pos3 = 0;
$len = strlen($str);
$ed2k = &#39;&#39;;
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(&#39;d:/log/a.txt&#39;,$ed2k,FILE_APPEND);
  echo substr($str,$pos1,$pos3+1).&#39;<hr/>&#39;;
  $i = $pos2;
}
?>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn