图片大小
php教程-php手册
关于直接采集远程机器图片之后再下载到我们本地其实非常的简单,我们通常会使用fopen 与 file_put_contents 或者高级点的curl来实现,下面我整理了几个比较好用的图片下载到本地例子,大家一起看看。搜刮源码,vscode 格式化段落,ubuntu 安装sci,tomcat支持的版本,都市爬虫club,html显示php内容,惠州好的企业seo公司,怎么下载app网站源码,如何下载易企秀的模板lzw
对于没有防盗链的图片跳跳球源码,ubuntu壁纸太糊,tomcat关闭控制台日志,小腿感觉像爬虫,登陆页面php,seo li 内容lzw
有防盗链的图片
互联idc php源码,ubuntu 打印测试页,爬虫宠物夜灯,openid php,影院 seo 网址lzw
curlg($url, $fromurl); $size = file_put_contents(getcwd() . $filepath . $filename . $ext, $re); //返回大小 return array( $filepath . $filename . $ext, $size );}?>
批量采集代码:
_get("keep"); //1从缓存获取2删除缓存/重新缓存 $id = $this->_get("id"); $id = $id ? $id : 0; $nextid = $id + 1; if ($keep != 1) { $data = M('Cjlist')->where("status=1")->select(); S("keepcjdata", $data, 3600); } else { $data = S("keepcjdata"); } $endid = count($data); //echo $id; //echo $endid; if ($endid == $id) { exit('所有图片下载完成!'); } //echo $endid; $data2['cover_imgurl'] = $this->imgdown2($data[$id]['cover_imgurl']); //echo $data[$id]['thum_url']; $data2['thum_url'] = $this->imgdown2($data[$id]['thum_url'], 'thum_'); //中型图片type $data2['id'] = $data[$id]['id']; if (!$data2['thum_url'] || !$data2['cover_imgurl']) { $data2['status'] = - 1; } else { $data2['status'] = 2; } $res = M('Cjlist')->save($data2); //$this->echosql(); if ($res) { echo '下载完成ID:' . $data2['id'] . " 前往下一个ID下载window.location.href='" . U('Index/downimg') . "/keep/1/id/" . $nextid . "'"; } else { echo '保存出错,正在重试刷新。window.location.reload()'; } //dump($data2); //dump($data); }?>
同时还可以生成缩略图哦
GrabImage2($picurl, $mulu, time() , $fromurl); //$img = file_get_contents($picurl); //echo file_put_contents('222.jpg',$img); //exit; //$reimg="/20140529/1401333398.jpg"; //dump($reimg); //exit; if ($reimg[1] thumb($imgurl, "thum_" . time() . $ext, '', '288', '432'); rename(getcwd() . "/" . $thum_name, getcwd() . $mulu . $thum_name); //移动到文件夹里面 $imginfo = $Image->getImageInfo(getcwd() . $mulu . $thum_name); //dump($imginfo); $imgarr['cover_url'] = $reimg; $imgarr['thum_url'] = $mulu . $thum_name; $imgarr['thum_w'] = $imginfo['width']; $imgarr['thum_h'] = $imginfo['height']; return $imgarr;}?>
本文地址:
转载随意,但请附上文章地址:-)