php 图片批量下载
来源:互联网 发布:unity3d 关卡编辑器 编辑:程序博客网 时间:2024/05/01 08:59
<?php $url = "http://photo.hupu.com/nba"; $content=file_get_contents($url); $reg="/<img.*?src=\"(.*?)\".*?>/"; preg_match_all($reg,$content,$matches); $path = './imgDownload'; if(!file_exists($path)){ mkdir($path, 0777); } for($i = 0;$i < count($matches[1]);$i ++){ /*explode $url_arr[$i] = explode('/', $matches[1][$i]); $last = count($url_arr[$i])-1; */ //strrchr $filename = strrchr($matches[1][$i], '/'); downImage($matches[1][$i],$path.$filename); //downImage($matches[1][$i],$path.'/'.$url_arr[$i][$last]); } function downImage($url,$filename="") { if($url=="") return false; if($filename=="") { $ext=strrchr($url,"."); if($ext!=".gif" && $ext!=".jpg" && $ext!=".png" && $ext!="jpeg") return false; $filename=date("YmdHis").$ext; } ob_start(); //make file that output from url goes to buffer readfile($url); //file_get_contents($url); 这个方法不行的!!!只能用readfile $img = ob_get_contents(); ob_end_clean(); $fp=@fopen($filename, "a");//append @fwrite($fp,$img); @fclose($fp); return $filename; }
0 0
- php 图片批量下载
- 通过PHP批量下载图片文件
- PHP多线程批量采集下载图片
- PHP多线程批量采集下载图片
- php批量下载图片并加水印
- php 实现图片批量下载的方法
- php 利用curl_multi_int 批量下载图片
- PHP批量下载图片文件(抓取css中图片)
- php 批量下载图片的一个小程序
- php批量下载网页图片并替换路径为本地
- PHP多线程批量采集下载美女图片的实现代码
- php 批量下载图片的一个小程序
- Python批量下载图片
- 批量下载大量图片
- 怎么批量下载图片
- node批量下载图片
- python批量下载图片
- python 批量下载图片
- button,textView改变背景进而改变整体外观
- 顺序表操作
- linux中的工作队列
- JavaSE_JDBC_Example01_BasicOP
- NYOJ 71 独木舟上的旅行
- php 图片批量下载
- poj 3311 Hie with the Pie dp+状压
- [SqlServer]-SqlServer Login User Schema Concept And Relation
- u-boot-2014.10移植第14天----在SDRAM中运行
- Codeforces Round #276 (Div. 2)(C贪心,D)
- C/C++实现正负数四舍五入
- Web负载均衡
- C库函数手册
- 的规范化个风格他发