<?php header("Content-type:text/html; Charset:utf8"); require_once 'PostHttp.class.php'; set_time_limit(0); //error_reporting(0); $http = new PostHttp(); $http->clearFields(); $url = get_big_pic('http://favefavefave.com/view/13146'); //my_copy($url, 'aaa.jpg'); //my_copy('http://pic.hellocache.com/2010/06/03/m/1184507678/4717ecb6bbf33f8156b54a90b392270f-1275556274.jpg', 'vv.jpg'); function get_big_pic($url) { global $http; //$tmp = file_get_contents($url); $http->postPage($url); $tmp = $http->getContent(); if (!$tmp) { return false; } $pattern = '|<div class="forme" id="view">.*?<p style="text-align:center;"><img src="(.*?)" alt=".*?" /></p>.*?via:\\s*?<a href="(.*?)">(.*?)</a>.*?</div>|is'; preg_match($pattern, $tmp, $row); array_shift($row); var_dump($row); //return $row[1]; } function my_copy($source, $dest) { /* $res = @copy($source, $dest); if( $res ) {
$pic = array(); foreach ($arr as $k => $v) { if ($v['url'] == '') { continue; } $pic_info = array(); $pic_info = get_big_pic($v['url']); if (!$pic_info) { //如果没获得大图地址 等待5秒再重新请求一次 sleep(5); $pic_info = get_big_pic($v['url']); } if (!$pic_info) { //如果没获得大图地址 等待5秒再重新请求一次 sleep(5); $pic_info = get_big_pic($v['url']); } if (!$pic_info) { continue; } $part_url = array(); $part_url = pathinfo($pic_info[0]); if (!$part_url['extension']) { continue; } $pic[$k]['title'] = empty($v['title']) ? 'Unknown' : $v['title']; $pic[$k]['name'] = $part_url['basename']; $pic[$k]['src'] = $pic_info[0]; $pic[$k]['via_name'] = empty($pic_info[2]) ? 'unknown' : $pic_info[2]; $pic[$k]['via_url'] = empty($pic_info[1]) ? '' : $pic_info[1]; //暂时放弃抓图