PHP CURL采集防盗链图片
匿名 · 更新于 2015/1/8
$ch = curl_init('http://www.xxx.com/DownloadImg/2011/05/1907/11838951_2.gif');
curl_setopt($ch, CURLOPT_REFERER, 'http://www.xxx.com/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$response = curl_exec($ch);
$fp = fopen('img/'.time().'.jpg', 'w');
fwrite($fp,$response);
fclose($fp);
if (curl_errno($ch) > 0) {
exit("CURL ERROR:$v " . curl_error($ch));
}
curl_close($ch);
