请问如何抓取其它的网站的image文件夹的所有图片,然后copy到自己网站里面?谢谢

解决方案 »

  1.   

    你得到他所有图片的地址就能保存图片到自己的服务器
    我自己写的一个方法 public function saveImage($img_arr,$img_path=''){
    if(empty($img_path)){
    $img_path = dirname($_SERVER['PHP_SELF']);
    }
    foreach($img_arr as $img_url){
     $newfname = $img_path . basename($img_url); 
     $file = fopen ($img_url, "rb"); 
     if ($file) {         
     $newf = fopen ($newfname, "wb");         
     if ($newf)         
     while(!feof($file)) {         
     fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );         
     }
     $log = fopen("img_v1_log.txt","a");
     fwrite($log,basename($img_url)."\r\n");
     } 
    if ($file) {         
     fclose($file);         
    }         
    if ($newf) {         
     fclose($newf);         
    }  
    }     
    }$img_path 保存图片的地址
    $img_arr 图片的地址 数组
    图片名称写在 img_v1_log.txt 这个文件