This day to work really tired ah, while this will be idle to write a crawl picture of the whole. Words not much on the code!!
1 <?Php2//The URL to crawl;3$url = ' http://www.zixue.it/';4//retrieving Web content;5$tmp =File_get_contents ($url);6//Regular get image address;7Preg_match_all ('/]*src= ' ([^ "]* (?: jpg|png|gif|jpeg))" [^>]*>/i ',$tmp,$res);8//Var_dump ($res);910Go heavy11$imgs =Array_unique ($res [1]);1213//Loop Save Picture14foreach$imgsAs$img){15//If the picture path is a relative path, it is converted to absolute path;16IfStripos ($img, '/http ') = = =False){17$img =$url.$img;18}19//Picture suffix;20$ext =PathInfo$img,Pathinfo_extension);21stif (! ($tmp =File_get_contents ($img))){22Continue;23}24if (file_put_contents ( Uniqid (). '. '. $ext, $tmp 25 echo "Picture". $img. " Download successful! <br/> "; }else{27 echo" <font color= ' red ' > pictures. $img. " Download failed! </font><br/> "; }29 }30"
Original address: http://lixiangfeng.com/blog/article/content/7810007 reprint please keep the original connection!! Thank you
PHP Remote Download pictures