PHP100 tips: PHP generates web page snapshots .? Outputs: Output Content image $ 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 size of the output image
/**
* Generate a web snapshot
* Fr bkJia.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 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;
}
Http://www.bkjia.com/PHPjc/508433.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/508433.htmlTechArticle? Php $ 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 output the content image...