Iecapt can capture Web pages, generate images in BMP, JPEG, or PNG format, including C + + and C # Two versions, not dependent on Internet Explorer, which determines that it can only be used under Windows. Iecapt is a command-line tool that uses the IE kernel to intercept its images by specifying a URL.
Operation:
First step:
Download Address iecapt:http://download.csdn.net/detail/u011986449/6877893
Step Two:
The following code:
<?php header (' Content-type:text/html;charset=utf-8 '); function Jietu ($url, $savepath) {//Web screenshot if (empty ($savepath)) {exit (' screenshot save directory is empty or not directory!
');
else {if (!file_exists ($savepath))//If the screenshot directory does not exist, create new {
mkdir ($savepath); } if (!url_exists ($url)) {exit (' URL address does not exist!
'); $filename =rtrim ($savepath, '/'). ' /'. Time (). '. PNG ';//assemble to generate screenshots of filename $rutycapt =dirname ($_server[' script_filename ')). '
/iecapt.exe '//Your native iecapt path $cmd = "$rutycapt--url= $url--out= $filename";/assemble Screenshots command System ($CMD);//execute command
Echo $cmd;
The function url_exists ($url) {//Judge whether the URL address exists $head = @get_headers ($url);
if (Is_array ($head)) {return true;
else {return false; } jietu (' http://www.csdn.net/', './img ');//url address can not omit www, omit the screenshot after the blank?>
In the PHP code above, enter the address of the Web page where you want to implement the snapshot, for example: Jietu (' http://www.csdn.net/', './img ');
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/PHP/