Code
Copy the Code code as follows:
$url = ' www.baidu.com '; Crawl Baidu
echo Snapshot ($url); Output as Image address
echo Snapshot ($url, './baidu.png '); Save picture to local baidu.png, output content picture size
/**
* Generate a snapshot of a webpage
*
* @param string $site Destination Address
* @param string $path Save the address, and the empty is not saved
* @param integer $dealy delay
* @return Mixed is returned according to the parameters
*/
function Snapshot ($site, $path = ", $dealy = 0)
{
$url = ' http://ppt.cc/yo2/catch.php ';
$query = ' url= '. $site. ' &delay= '. $dealy. ' &rnd= '. Mt_rand (1, 9);
$ch = Curl_init ($url);
curl_setopt ($ch, Curlopt_post, true);
curl_setopt ($ch, Curlopt_postfields, $query);
curl_setopt ($ch, curlopt_useragent, $_server[' http_user_agent ');
curl_setopt ($ch, Curlopt_returntransfer, true);
$data = curl_exec ($ch);
Curl_close ($ch);
if (strlen ($data)! = 32) {
Exit (' invalid URL ');
}
$file = $data {0}. '/' . $data {1}. '/' . $data {2}. '/';
$file = ' http://cache.ppt.cc/'. $file. ' Src_ '. $data. '. png ';
if (!empty ($path)) {
$data = file_get_contents ($file);
Return file_put_contents ($path, $data);
}
return $file;
}
?>
The above describes the page snapshot where PHP generated page snapshot without COM without extension, including the page snapshot in what aspect of the content, I hope that the PHP tutorial interested in a friend helpful.