How to get all the fixed-seed links in a Web page by PHP _php tips

Source: Internet
Author: User
Tags php programming php regular expression

The example in this article describes how to obtain all the fixed-seed links in a Web page in PHP. Share to everyone for your reference, specific as follows:

Frequent download links are more often, just like all the links added to the Thunderbolt or electric stove, but not in this option, how to do, we are phper ah, this thing is not difficult to us

And look at the code, of course, to replace you, according to the specific circumstances to make changes.

<?php
Header ("Content-type:text/html;charset=utf8");
$str = file_get_contents ('./showfile.asp ');
$str 1 = ' <a href= ' ed2k ';
$str 2 = ' > ';
$pos 1 = 0;
$pos 2 = 0;
$pos 3 = 0;
$len = strlen ($STR);
$ed 2k = ';
for ($i =5000; $i < $len;) {
  $pos 1 = strpos ($str, $str 1, $i) + 9;
  $pos 2 = Strpos ($str, $str 2, $pos 1)-2;
  $pos 3 = $pos 2-$pos 1;
  Indicates that the feature connection no longer exists discard look for
  if ($pos 1 = = 9) {break;}
  $ed 2k = substr ($str, $pos 1, $pos 3+1). " \ r \ n ";
  File_put_contents (' D:/log/a.txt ', $ed 2k,file_append);
  Echo substr ($str, $pos 1, $pos 3+1). '  
 

More about PHP Interested readers can view the site topics: "Php Curl Usage Summary", "PHP array" operation Skills Daquan, "PHP Sorting algorithm Summary", "PHP common traversal algorithm and skills summary", "PHP Data structure and algorithm tutorial", " PHP Programming algorithm Summary, "PHP Mathematical Calculation Skills Summary", "PHP Regular Expression Usage summary", "PHP operation and operator Usage Summary", "PHP string (String) Usage summary" and "PHP common database Operation skill Summary"

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.