Home > Backend Development > PHP Tutorial > 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

高洛峰
Release: 2023-03-03 13:38:01
Original
1755 people have browsed it

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;
}
?>
Copy after login


Related labels:
php
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template