php - 采集图片下载到本地 ,win下正常 linux上图片损坏
ringa_lee
ringa_lee 2017-04-10 14:50:25
0
1
619

如题

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;
    }
ringa_lee
ringa_lee

ringa_lee

répondre à tous(1)
Peter_Zhu
<?php
/*
*   暴走漫画Down工具 V 3
*/
include 'heimingdan.php';
$destination_folder = 'D:\baozoumanhua/';
print "存储图片文件夹:" . $destination_folder . "\n";
print "暴走漫画离线下载工具 V3 by y0umer \n";
print "============ 暴走漫画 V3 Y0UMER ==============\n";
set_time_limit(0);
$pregcode = "/http:\/\/ww\d.sinaimg.cn\/(.*).jpg/m";
global $source,$cs,$down_url;
print "[301] 正在启动下载引擎... \n";
for($j=1;$j<100;$j++){
$source .= file_get_contents('http://baozoumanhua.com/tucao/fresh/page/' . $j);
$sources = strip_tags($source, '<img>');
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<count($heimingdan);$f++)
        {
            if(strpos($val,$heimingdan[$f]))
            {
                print "[403]发现黑名单文件" . $val . "跳出!\n";
                continue;
            }
        }
    
    // 这里是执行....
     $file = fopen($val, "rb");
    if ($file) {
        $newf = fopen($newfname, "wb");
        if ($newf)
            while (!feof($file)) {
            print "[200]尝试下载:" . $val . "\n";
                fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
                 
            }
    }
    if ($file) {
        fclose($file);
    }
    if ($newf) {
        fclose($newf);
    }   
    }   
     print "[000] 所有暴漫图片下载完毕,请阅读..." . "\n";
 
?>

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal