如何使用PHP和GD截取网站的屏幕截图? [英] How can I take a screenshot of a website with PHP and GD?
本文介绍了如何使用PHP和GD截取网站的屏幕截图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用PHP和GD库创建网站的屏幕截图.
How can I create a screenshot of a website using PHP and the GD library.
推荐答案
虽然您可以使用
While you might be able to do something with imagegrabscreen
or imagegrabwindow
you'd only be able to use it on a Windows box, and even then it would be tricky.
您必须打开浏览器窗口以找到指定的url(您可以使用exec
进行此操作),并使用上述方法抓取屏幕截图.
You'd have to open a browser window to the specified url (you could do that with exec
) and grab a screenshot using the aforementioned methods.
以下是 imagegrabwindow
的手册条目中的示例:
Here's an example from the manual entry for imagegrabwindow
:
<?php
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("http://www.libgd.org");
/* Still working? */
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "iesnap.png");
imagedestroy($im);
?>
这篇关于如何使用PHP和GD截取网站的屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文