Follow suit. use PHP to show your sister-PHP source code

Source: Internet
Author: User
Follow suit, jump

2) {foreach ($ matchs [2] as $ k => $ v) {$ links [$ v] = $ matchs [1] [$ k];} return $ links;} function getImgUrls ($ url) {$ html = file_get_contents ($ url); preg_match_all ('', $ html, $ matchs); return count ($ matchs)> 1? $ Matchs [1]: null;} function getImage ($ path, $ url) {preg_match ('/img \/(\ w + )\. jpg/', $ url, $ match); $ filepath = $ path. DIRECTORY_SEPARATOR. $ match [1]. '.jpg '; ob_start (); readfile ($ url); $ img = ob_get_contents (); ob_end_clean (); $ fp = @ fopen ($ filepath, 'A '); fwrite ($ fp, $ img); fclose ($ fp);} while ($ page $ v) {$ k = str_replace ('','', $ k ); // for GBK-encoded Windows, the following line must be converted to the character format // $ k = mb_convert_encodi Ng ($ k, 'gb2312', 'utf-8'); $ k = strip_tags ($ k); if (! File_exists ($ k) {echo '>>> Make directory '. $ k. PHP_EOL; mkdir ($ k, 0755, true);} $ img_urls = getImgUrls ($ v); foreach ($ img_urls as $ key => $ value) {echo '> Downloading '. $ value. PHP_EOL; getImage ($ k, $ value) ;}}$ page ++ ;}
Related Article

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.