您好,欢迎访问一九零五行业门户网

php 抓取图片

get, 'timeout'=>3,//设置3秒等待 ), ); if(is_array($getdata) && !empty($getdata)) { $ser = http_build_query($getdata, '', '&'); } $cnt=0; //如果请求失败 继续请求3次 while($cnt/i, $file, $matches); if(empty($matches[0]) || empty($matches[1])) { echo not img...;die; } $imgs=array_unique($matches[1]); foreach($imgs as $k=>$img) { $filename = $path.time().$k..jpg; getimage($img,$filename); }}/** * @param string $url * @param string $filename * 保存图片 */function getimage($url = '', $filename = ''){ var_dump($filename); $ch = curl_init(); $fp = fopen($filename, 'wb'); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_file, $fp); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_followlocation, 1); curl_setopt($ch, curlopt_timeout, 60); curl_exec($ch); curl_close($ch); fclose($fp);}
其它类似信息

推荐信息