p.s.需要采集远程图片就需要先判断是否存在,这里提供一个函数,通过文件头来判断
不同状态下读取的header信息
找到图片
Array
(
[0] => HTTP/1.1 200 OK
[1] => Date: Mon, 08 Jul 2013 05:27:31 GMT
[2] => Server: Apache
[3] => P3P: CP=" OTI DSP COR IVA OUR IND COM "
[4] => Set-Cookie: BAIDUID=8133EE2CEB85AB13776316F0C72CEDE0:FG=1; expires=Tue, 08-Jul-14 05:27:31 GMT; max-age=31536000; path=/; domain=.baidu.com; version=1
[5] => Last-Modified: Thu, 20 Jan 2011 07:15:35 GMT
[6] => ETag: "65e-49a41e65933c0"
[7] => Accept-Ranges: bytes
[8] => Content-Length: 1630
[9] => Cache-Control: max-age=315360000
[10] => Expires: Thu, 06 Jul 2023 05:27:31 GMT
[11] => Connection: Close
[12] => Content-Type: image/gif
)
未找到图片但是做了404跳转
Array
(
[0] => HTTP/1.1 200 OK
[1] => Server: Apache/1.3.37.sa
[2] => Date: Mon, 08 Jul 2013 06:11:26 GMT
[3] => Content-Type: text/html
[4] => Content-Length: 1576
[5] => Last-Modified: Fri, 10 Feb 2012 06:48:17 GMT
[6] => Connection: close
[7] => Accept-Ranges: bytes
)
未找到图片
Array
(
[0] => HTTP/1.1 404 Not Found
[1] => Server: nginx
[2] => Date: Mon, 08 Jul 2013 05:29:43 GMT
[3] => Content-Type: text/html
[4] => Content-Length: 162
[5] => Connection: close
)
评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=2090
function is_img_exist($url){
//print_r(get_headers("http://uc.discuz.net/data/avatar/000/00/022/03_avatar_small.jpg"));
//exit;
$result = get_headers($url);
$str_result = implode(",", $result);
if( substr_count( $str_result, "image" ) ){
return true;
}else{
return false;
}
}
//print_r(get_headers("http://uc.discuz.net/data/avatar/000/00/022/03_avatar_small.jpg"));
//exit;
$result = get_headers($url);
$str_result = implode(",", $result);
if( substr_count( $str_result, "image" ) ){
return true;
}else{
return false;
}
}
不同状态下读取的header信息
找到图片
Array
(
[0] => HTTP/1.1 200 OK
[1] => Date: Mon, 08 Jul 2013 05:27:31 GMT
[2] => Server: Apache
[3] => P3P: CP=" OTI DSP COR IVA OUR IND COM "
[4] => Set-Cookie: BAIDUID=8133EE2CEB85AB13776316F0C72CEDE0:FG=1; expires=Tue, 08-Jul-14 05:27:31 GMT; max-age=31536000; path=/; domain=.baidu.com; version=1
[5] => Last-Modified: Thu, 20 Jan 2011 07:15:35 GMT
[6] => ETag: "65e-49a41e65933c0"
[7] => Accept-Ranges: bytes
[8] => Content-Length: 1630
[9] => Cache-Control: max-age=315360000
[10] => Expires: Thu, 06 Jul 2023 05:27:31 GMT
[11] => Connection: Close
[12] => Content-Type: image/gif
)
未找到图片但是做了404跳转
Array
(
[0] => HTTP/1.1 200 OK
[1] => Server: Apache/1.3.37.sa
[2] => Date: Mon, 08 Jul 2013 06:11:26 GMT
[3] => Content-Type: text/html
[4] => Content-Length: 1576
[5] => Last-Modified: Fri, 10 Feb 2012 06:48:17 GMT
[6] => Connection: close
[7] => Accept-Ranges: bytes
)
未找到图片
Array
(
[0] => HTTP/1.1 404 Not Found
[1] => Server: nginx
[2] => Date: Mon, 08 Jul 2013 05:29:43 GMT
[3] => Content-Type: text/html
[4] => Content-Length: 162
[5] => Connection: close
)
[最后修改由 admin, 于 2013-07-09 12:30:21]

这篇日志没有评论。
此日志不可发表评论。