search
Homephp教程php手册PHP100精华:PHP生成网页快照

PHP100精华:PHP生成网页快照

Jun 13, 2016 am 10:33 AM
echophpsnapurlSnapshotcrawlgenerateBaiduEssenceWeb page

$url = www.baidu.com; //抓取百度
echo snapshot($url);  //输出结果为图片地址
echo snapshot($url, ./baidu.png); //将图片保存至本地baidu.png, 输出内容图片大小

/**
 * 生成网页快照
 * Fr bkJia.com 论坛 xiaokai
 * @param   string  $site   目标地址
 * @param   string  $path   保存地址, 为空则不保存
 * @param   integer $dealy  延迟
 * @return  mixed   根据参数返回
 */
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(无效网址);
    }


    $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;
}
 

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.