PHP-网页截图-网页快照
单纯使用PHP很难实现,还好有个比较适中的解决方案:
http://cutycapt.sourceforge.net/
不过要求主机环境的支持:
Linux : 要求安装了qt或x-server
Windows:要求安装了IE(^_…)
下边分别以两种环境开始:
Windows :
1.下载 CutyCapt-Win32-2008-06-11.zip (6MB, .exe for Win32 systems)
2.
<?php //要截图的网址 $url = 'http://www.zhaipeng.cn/'; //输出的图片名称 $out = 'ex.png'; $path = 'CutyCapt/CutyCapt.exe';//下载位置 $cmd = "$path --url=$url --out=$out"; //exec($cmd); system($cmd); ?> |
Linux :
安装了qt的Linux主机 :
Build Instructions
If your system is set up to compile Qt applications, building CutyCapt should be a simple matter of checking out the source code and running qmake and your version of make. As an example, if you are running Ubuntu Hardy Heron and have configured the system to use packages from hardy-backports, the following should do:
% sudo apt-get install subversion libqt4-webkit libqt4-dev g++
% svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt
% cd cutycapt/CutyCapt
% qmake
% make
% ./CutyCapt –url=http://www.example.org –out=example.png
安装了x-server的Linux主机 :
Using CutyCapt without X server
You cannot use CutyCapt without an X server, but you can use e.g. Xvfb as light-weight server if you are not running an interactive graphical desktop environment. For example, you could use:
% xvfb-run –server-args=”-screen 0, 1024x768x24″ ./CutyCapt –url=… –out=…
使用帮助:
Usage
Open a command prompt and ask for help:
% CutyCapt –help
—————————————————————————–
Usage: CutyCapt –url=http://www.example.org/ –out=localfile.png
—————————————————————————–
–help Print this help page and exit
–url=
–out=
–out-format=
–min-width=
–max-wait=
–delay=
–user-styles=
–header=
–method=
–body-string=
–body-base64=
–app-name=
–app-version=
–user-agent=
–javascript=
–java=
–plugins=
–private-browsing=
–auto-load-images=
–js-can-open-windows=
–js-can-access-clipboard=
—————————————————————————–


