php实现网页截图的方法:首先安装Qt47,利用CutyCapt实现网页截图;然后安装CutyCapt,并下载【x-server】;接着安装中文包以及ImageMagick;最后com.cn/tag/%e6%b5%8b%e8%af%95" target="_blank">测试并下载64位flash插件。
【相关学D l % ! 7 R习推荐:php编程(视频)】
php实现网页截图的方法:
网页截图这个功能大家可能用到最多的就是QQ截图,或利用asp.net来实现截图,其实我U K } 3 1 Q 2们也可以直接使用php来网页截图,这里就来给大家介绍php利用CutyCapt实[ } M现网页截图的流程:
Cuty= E - J b 8 G I )Capt下载地址:http://sourceforge.net/projects/c- Q z V C 1 p $ut; s p # . x N cycapt/files/cutyq [ U P , 7 2 Wcapt/
windows CutyCapt不需要安装,直接保存到w A m Z =你的电脑中即可,然后php代码如下写:
<?php /* 网页截图功能,必须安装IE+CutyCapt url:要截图的网页 out:图片保存路径 path:CutyCap6 F #t路径 cmd:w { ACutyCapt执行命令 比如:http://你php路径.php?url=https://www.jb51.net */[ n U z $url=$_GET["url"]; $imgname=str_replace('http://','',$url); $imgname=str_replace('https://','',$imgname); $imgname=str@ D 9_replace('.','-',$imgname); $out = 'D:/webroot/test/'.$imgname.'.pnd Y ?g'; $path = 'D:/webserver/CutyCapt.exe'; $cmd = "$path --url=$url --out=$out"; echo $cmd; sysC u R jtem($cmd); ?>
如果你是linux系统就需要简单2 K x B 4 5 0 {的配置一下CutyCapt,安装网站截图软件CutyCapt.
一、先安装Qt47,增加qt47的下载源,代码如下? [ m - R:
vi /etc/yum.repos.d/atrpms.repo [atrpms] name=CentOS $J E ~ E rreleasever – $basearcm O l k U ; ph – ATrpms baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/stable gpgkey=h 0 $ Ettp://ATrpms.net/RPM-GPG-KEY.atrZ 1 m / [ R ^ + dpm- [ ` `s gpgc, [ vhe, y 7 ^ 8 # 7 Wck=1 enabled=1 [atrpms-testing] name=CentOS $releasever – $basearch – ATrpms testing baseurl4 l ,=http://dl.atrpms.net/el$releasever-w e o$basearch/atrpms/testing gpgkey=http://ATrpms.net/RP| L JM-GPG-KEY.atrpms gpgche9 = = wck=1 enw & #abled=1 yum update yum installqt47 yum installqt47-devel yum installqt47-webkit yur B | ? ?m inG - s E )stallqt| 1 ~ h J e M r47-webkit-devel
也许这里还会有报错提示:
warningI X L i L F L s :: qt44-x11-4.4.3-10_4.el5.xs c h X86_64.rpm: Header V4 DSA signature: NOKEY, key ID 66534c2b error: Failed dependencies: libGLU.so.1& ] R g ( b P j()(64bit) is needed by qt44-= w R C zx11-4.4.3-10_4: 9 -.el5.x86_64 li{ G j T Q h @bmng.so.1()(64bit) iw d e } X W #s needed by qt44-x11-4.4.3-10_4.el5.x86_64
//解决:
//yum -y installqt-devel*
二、安装 CutyCal 8 M a T % 8 @pt,代码如下:
cd /data0/sH w 1 M ^ u Ioftware svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt mv cutycapt/CutyCapt /usr/local/cuth v * ! :ycapt cd /usr/local/cutycapt qmake mQ m l g S .ake
此处可能会报错:
make: *** [CutyCapt] Error 1
解决:yum update sqlite,再次执行 make,如果还不成功 qmaP ? + = t % 7 ^ke-qt47 再次执行make.
三, ( { B 9 ;、下载x-server V S s Vr,代码如下:
wget http://www.flex- d 0 K %thinker.com/wp-content/uploads/2009/11/xvfb-run.sh.txt mv ./xvfb-run.sh.txt/usr/local/cL p tutycapt/xvfb-run.sh chmodu+x /usr/local/CutyCapt/xvfb-run.sh
四、安装中文包
yum installfonts-chinese
五、安装ImageMaf , R 7 ~ w $gick
yum installIu 8 : gmag1 k ] teMagick
六、测试,代码如下:
/N x K iusr/local/cutycapt/xvfb-run.sh --server-args="-screen 0, 1024x768x24"/Y T / @usr/local/cutyc_ , 6apt/CutyCapt --url=https://www.jb51.n( c = J I |et--out=/tmp/163.jpg
163.jpg没有加载出flash.
七、下载64位fl9 = + 0 o ^ ! ` uash插件,代码如下:
cd /data0/software #wget http://119.188.72.26/1/ishare.down.sina.com.cn/14036482.so?ssig=YB70Xk7Ph9&Expires=1340899200&2 R = J hamp;KID=sina,ishare&ip=1340777795,11T X D4.255.44.&fn=li8 v b V n o w gbflashplayer.so http://ishare.iask.sina.com.cn/f/13659493^ L S g = c H.h0 y Y c + | 3tml ll /usr/lib64/mozilla/plugins/ lrwxrwxrwx 1 root root 41 06-27 14:g O F00 libflashplayer.so ->/usl s n |r/lib64/flash-plugi 4 O @ } 4 , wn/libflashplf g ) Q jayer.so cp /data0/software/libflashplayer.so /usr/lib64/flash-plugin/
【相关学习推荐:php图文教程】
以上就是php怎样实现网页截图的详细内容。