Maison > php教程 > php手册 > le corps du texte

PHP imagegrabscreen和imagegrabwindow(截取网站缩略图)的实例代码

WBOY
Libérer: 2016-06-13 09:31:09
original
801 Les gens l'ont consulté

1. 截取整个屏幕 Screenshot

复制代码 代码如下:


$im = imagegrabscreen();   
imagepng($im, “myscreenshot.png”);   
?>


2. 截取一个窗口 Capture a window (IE for example)

复制代码 代码如下:


$browser = new COM(“InternetExplorer.Application”);   
$handle = $browser->HWND;   
$browser->Visible = true;   
$im = imagegrabwindow($handle);   
$browser->Quit();   
imagepng($im, “iesnap.png”);   
$im = imagegrabscreen();   
?>


3. 截取IE内容 Capture a window (IE for example) but with its content!

复制代码 代码如下:


$browser = new COM(“InternetExplorer.Application”);   
$handle = $browser->HWND;   
$browser->Visible = true;   
$browser->Navigate(“http://www.jb51.net”);   

/* Still working? */  
while ($browser->Busy) {   
     com_message_pump(4000);   
}   
$im = imagegrabwindow($handle, 0);   
$browser->Quit();   
imagepng($im, “iesnap.png”);   
?>


4. 截取IE的全屏模式 IE in fullscreen mode

复制代码 代码如下:


$browser = new COM(“InternetExplorer.Application”);   
$handle = $browser->HWND;   

$browser->Visible = true;   
$browser->FullScreen = true;   
$browser->Navigate(“http://www.jb51.net”);   

/* Is it completely loaded? (be aware of frames!)*/  
while ($browser->Busy) {   
     com_message_pump(4000);   
}   
$im = imagegrabwindow($handle, 0);   
$browser->Quit();   
imagepng($im, “iesnap.png”);   
?>


上面就是说如何使用PHP COM调用IE窗口打开网页进行截屏,但很多朋友得到的结果只是一张纯黑的图片,这是为什么呢?
可能有两种情况,第一种情况就是这个COM组件只适用于WINDOWS服务器,其它系统的服务器是不支持的,因为他没有IE浏览器,第二种情况就是没有打开允许服务与桌面交互!其中第二种情况最为常见,打开的方法就是点击计算机(我的电脑) -> 右键 -> 管理 -> 服务和应用程序 -> 服务 -> Apache(我自己使用apache服务器) -> 右键 -> 属性 -> 登录 -> 登录身份下面既是!
Étiquettes associées:
php
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Recommandations populaires
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!