? Php $ url = 'www .baidu.com '; // capture Baidu echosnapshot ($ url); // The output result is the image address echosnapshot ($ url ,'. /baidu.png '); // save the image to baibaidu.png, and output the image size/*** generate a webpage snapshot * FrPHP100.
$ Url = 'www .baidu.com '; // capture Baidu
Echo snapshot ($ url); // The output result is the image address.
Echo snapshot ($ url, './baidu.png'); // save the image to baibaidu.png, and the image size of the output content.
/**
* Generate a web snapshot
* Fr PHP100.com Forum xiaokai
* @ Param string $ site destination address
* @ Param string $ path: save address. if it is null, it is not saved.
* @ Param integer $ dealy latency
* @ Return mixed return 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 website ');
}
$ 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;
}