代码
<BR><?php <BR>$url = 'www.baidu.com'; //抓取百度 <BR>echo snapshot($url); //输出结果为图片地址 <BR>echo snapshot($url, './baidu.png'); //将图片保存至本地baidu.png, 输出内容图片大小 <BR>/** <BR>* 生成网页快照 <BR>* <BR>* @param string $site 目标地址 <BR>* @param string $path 保存地址, 为空则不保存 <BR>* @param integer $dealy 延迟 <BR>* @return mixed 根据参数返回 <BR>*/ <BR>function snapshot($site, $path = '', $dealy = 0) <BR>{ <BR>$url = 'http://ppt.cc/yo2/catch.php'; <BR>$query = 'url=' . $site . '&delay=' . $dealy . '&rnd=' . mt_rand(1, 9); <BR>$ch = curl_init($url); <BR>curl_setopt($ch, CURLOPT_POST, true); <BR>curl_setopt($ch, CURLOPT_POSTFIELDS, $query); <BR>curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); <BR>curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); <BR>$data = curl_exec($ch); <BR>curl_close($ch); <BR>if (strlen($data) != 32) { <BR>exit('无效网址'); <BR>} <BR>$file = $data{0} . '/' . $data{1} . '/' . $data{2} . '/'<mark>6来源gaodaimacom搞#^代%!码网</mark><strong>搞gaodaima代码</strong>; <BR>$file = 'http://cache.ppt.cc/' . $file . 'src_' . $data . '.png'; <BR>if (!empty($path)) { <BR>$data = file_get_contents($file); <BR>return file_put_contents($path, $data); <BR>} <BR>return $file; <BR>} <BR>?> <BR>