Home > php教程 > php手册 > body text

php根据url生成网页快照的方法(附代码)

PHPz
Release: 2018-10-22 15:35:57
forward
1904 people have browsed it

这篇文章主要介绍了php根据url生成网页快照的方法,有一定的参考价值,感兴趣的朋友可以参考一下。

<form method="post" action="">
<input type="text" name="url" />
<input type="submit" value="提交" />
</form>
<?php
/* 
网页截图功能,必须安装IE+CutyCapt
url:要截图的网页
out:图片保存路径
path:CutyCapt路径
cmd:CutyCapt执行命令
比如:http://你php路径.php?url=http://www.xxx.com
*/
function Generatepictures($url){
$url=$url;
$imgname=str_replace(&#39;http://&#39;,&#39;&#39;,$url);
$imgname=str_replace(&#39;https://&#39;,&#39;&#39;,$imgname);
$imgname=str_replace(&#39;.&#39;,&#39;-&#39;,$imgname);
$out = &#39;D:/gongzuo/tupian/&#39;.$imgname.&#39;.png&#39;;
$path = &#39;D:/CutyCapt.exe&#39;;
$cmd = "$path --url=$url --out=$out";
echo "<img src=&#39;http://localhost/tupian/".$imgname.".png&#39; />";
system($cmd);
}
if (isset($_POST[&#39;url&#39;]))  
    {
        Generatepictures($_POST[&#39;url&#39;]);
    }
?>
Copy after login

 【相关教程推荐】

1. php编程从入门到精通全套视频教程
2. php从入门到精通 
3. bootstrap教程

Related labels:
source:csdn.net
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template