Home >Backend Development >PHP Tutorial >CutyCapt in php implements web page screenshot saving code_PHP tutorial
The function of web page screenshots that you may use most is QQ screenshots, or using asp.net to realize screenshots. In fact, we can also directly use php to take web page screenshots. Now I will introduce to you how to use CutyCapt to realize web page screenshots in PHP. If necessary Friends can refer to it.
CutyCapt download address: http://sourceforge.net/projects/cutycapt/files/cutycapt/
Windows CutyCapt does not require installation, just save it directly to your computer.
Then write your php code as follows
The code is as follows | Copy code | ||||||||
url: want to screenshot Web page
$imgname=str_replace( 'https://','',$imgname); |
代码如下 | 复制代码 |
cd /data0/software svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt mv cutycapt/CutyCapt /usr/local/cutycapt cd /usr/local/cutycapt qmake make |
#wget http://119.188.72.26/1/ishare.down.sina.com.cn/14036482.so?ssig=YB70Xk7Ph9&Expires=1340899200&KID=sina,ishare&ip=1340777795 ,114.255.44.&fn=libflashplayer.so
First, install Qt47 first
Add the download source of qt47
Maybe there will be an error message herewarning: qt44-x11-4.4.3-10_4.el5.x86_64.rpm: Header V4 DSA signature: NOKEY, key ID 66534c2berror: Failed dependencies: libGLU.so.1()(64bit) is needed by qt44-x11-4.4.3-10_4.el5.x86_64 libmng .so.1()(64bit) is needed by qt44-x11-4.4.3-10_4.el5.x86_64Solution: yum -y installqt-devel* II , install CutyCapt The code is as follows
Copy code vi /etc/yum.repos .d/atrpms.repo
[atrpms]
name=CentOS $releasever – $basearch – ATrpmsbaseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/stable
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
enabled=1
[atrpms-testing]name=CentOS $ releasever – $basearch – ATrpms testingbaseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/testinggpgkey=http://ATrpms.net/RPM-GPG-KEY .atrpmsgpgcheck=1enabled=1 yum updateyum installqt47yum installqt47-develyum installqt47-webkityum installqt47-webkit-devel 代码如下 复制代码
wget http://www.flexthinker.com/wp-content/uploads/2009/11/xvfb-run.sh.txt
mv ./xvfb-run.sh.txt/usr/local/cutycapt/xvfb-run.sh
chmodu+x /usr/local/CutyCapt/xvfb-run.sh
An error may be reported heremake: *** [CutyCapt] Error 1Solution: yum update sqliteExecute make again If it still fails qmake-qt47 Execute make again Three, download x-server The code is as follows Copy code cd /data0/softwaresvn co https://cutycapt.svn.sourceforge.net/svnroot/cutycaptmv cutycapt/CutyCapt /usr/local/cutycaptcd /usr/local/cutycaptqmakemake
The code is as follows Copy code wget http://www.flexthinker.com/wp-content/uploads/2009/11/xvfb-run.sh.txtmv ./xvfb-run .sh.txt/usr/local/cutycapt/xvfb-run.shchmodu+x /usr/local/CutyCapt/xvfb-run.sh
Four. Install the Chinese package
yum installfonts-chinese
Five. Install ImageMagick
yum installImageMagick
Six. Test:
The code is as follows
代码如下 复制代码 /usr/local/cutycapt/xvfb-run.sh --server-args="-screen 0, 1024x768x24"/usr/local/cutycapt/CutyCapt --url=http://www.bkjia.com--out=/tmp/163.jpg
Copy code
/usr/local/cutycapt/xvfb-run.sh --server-args="-screen 0, 1024x768x24"/usr/local/cutycapt/CutyCapt --url=http://www.bkjia .com--out=/tmp/163.jpg Seven, download the 64-bit flash plug-in :
代码如下 复制代码 cd /data0/software
#wget http://119.188.72.26/1/ishare.down.sina.com.cn/14036482.so?ssig=YB70Xk7Ph9&Expires=1340899200&KID=sina,ishare&ip=1340777795,114.255.44.&fn=libflashplayer.so
http://ishare.iask.sina.com.cn/f/13659493.html
ll /usr/lib64/mozilla/plugins/
lrwxrwxrwx 1 root root 41 06-27 14:00 libflashplayer.so ->/usr/lib64/flash-plugin/libflashplayer.so
cp /data0/software/libflashplayer.so /usr/lib64/flash-plugin/
163.jpg flash is not loaded
The code is as follows
Copy code
cd /data0/software