- 论坛徽章:
- 0
|
- $folder = BASE_DIR.'/tmp/avn/';
- $nums = array(20,40,60,80,100,120,140,160,180,200,220);
- foreach ($nums as $num){
- $url = "http://image.baidu.com/i?z=0&cl=2&ct=201326592&sn=&lm=-1&cm=1&sc=0&bu=&rn=21&tn=baiduimage&word=%CD%B7%CF%F1&pn=$num";
- $content = file_get_contents($url);
- $regexp = '|target=_blank><img src=(http://\w\d.baidu.com/it/u=\d*,\d*&gp=\d*.jpg)></a><br>|iU';
- preg_match_all($regexp,$content,$need);
- fuck_av($need[1]);
- }
- function fuck_av($array){
- foreach ($array as $img){
- saveImage($img);
- }
- }
- echo '保存完毕!';
- function saveImage($uri){
- global $folder;
- $file = time().'_'.rand(0,9999).'.jpg';
- $file = $folder.$file;
- $fp = fopen($file,'w');
- @fwrite($fp,getvarable($uri));
- @fclose($fp);
- if(file_exists($file))
- _log($file."\t保存完毕\r\n");
- }
- function _log($str){
- $file = BASE_DIR.'/log/image.'.date('Y_m_d').'.txt';
- $fp = fopen($file,'a+');
- @fwrite($fp,$str);
- @fclose($fp);
- }
复制代码 |
|