Simple crawling based on PHPQuery (3) -- replacing the list page link

Source: Internet
Author: User
4. finally, in order to make the document page truly a local page, the last step is to replace the link of the targeted content of the list page with the local link, which is quite simple: & lt ;? Phpset_time_limit (0); require_once (& quot;.../phpQuery. php & quot ;);

4. Finally, in order to make this document page truly a local page, we need to take the last step, that is, replacing the link of the targeted content of the list page with the local link, which is quite simple:

 Html (); $ arr = preg_split ("/\ n/", $ a); unset ($ arr [0]); // print_r ($ arr ); foreach ($ arr as $ key => $ value) {preg_match ("/(. *) <\/a>/", $ value, $ array); $ tailarr = explode ("/", $ array [1]); // echo $ tailarr [count ($ tailarr)-1]."
"; $ Tails = $ tailarr [count ($ tailarr)-1]; $ tail = strtolower ($ tails); $ taillink = ". /". $ tail. ". html "; pq (". vt li: eq (". ($ key-1 ). ")")-> find ("a")-> attr ("href", $ taillink);} $ content = pq (". vt ")-> html (); file_put_contents (". /manual/index.html ", $ content); echo" the link is replaced successfully!
";

At this point, we have completed all the work of capturing the phpquery document content to generate local documents, and also learned the basic operations of phpquery:

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.