当前位置:Gxlcms > PHP教程 > 采集图片下载到本地,win下正常linux上图片损坏

采集图片下载到本地,win下正常linux上图片损坏

时间:2021-07-01 10:21:17 帮助过:6人阅读

如题

function curl_link($url){
        $HTTP_Server=$url; 
        $ch = curl_init(); 
        curl_setopt ($ch,CURLOPT_URL,$HTTP_Server); 
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); 
        curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; c8650 Build/GWK74) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 MQQBrowser/4.5 Mobile Safari/533.1s"); 
        $res = curl_exec($ch); 
        curl_close ($ch); 
        return $res;
    }

回复内容:

如题

function curl_link($url){
        $HTTP_Server=$url; 
        $ch = curl_init(); 
        curl_setopt ($ch,CURLOPT_URL,$HTTP_Server); 
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); 
        curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; c8650 Build/GWK74) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 MQQBrowser/4.5 Mobile Safari/533.1s"); 
        $res = curl_exec($ch); 
        curl_close ($ch); 
        return $res;
    }

');
print "[301] 正在分析{$j}页图片文件 \n";
}
$imgurl = array();
$url = '';
if (preg_match_all($pregcode, $sources, $imgurl)) { 
    unset($sources);
    $url = $imgurl[0];
    
    unset($imgurl);
}
// 处理黑名单

foreach ($url as $key => $val) {
    $newfname = $destination_folder . "ITSEC-" .mt_rand(0,99).$key . '.jpg';
      for($f=0;$f

人气教程排行