Page snapshot where PHP generates a Web page snapshot without com without extension

Source: Internet
Author: User
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.