如何取得網站的版面圖?

以前看到一些搜尋器,當你搜尋到一堆網站出來,搜尋器還會連帶著那堆網站的版面圖,今天就是在想這個要如何實現出來,最後找了很多相關的API或網站(WebSnapr,WebThumb),最後還是使用PHP的GD比較好,可是不知道當流量大時,會不會讓Server無法負責?

以下是環境相關:
-PHP 5.2.X
-PHP GD2

1.Print screen

$im = imagegrabscreen();
imagepng($im, "myscreenshot.png");


2.取得InternetExplorer的圖片

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


3.去掉InternetExplorer的程式外框,只取得網站版面

$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Fullscreen = true;
$browser->Navigate("http://www.domain.com");

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


問題來了...發現並不是每次也能成功地取得圖片,上網再找相關的問題,最後找到答案,但不知道是不是完美的答案=.="(汗)
現在我們需要設定Apache,以下是相關的步驟:
1.right-click My Computer
2.select Manage/Services and Applications/Services
3.find the apache service (like Apache2) and right-click, select Properties
4.choose the Log on tab and check the 'Allow service to interact with desktop' checkbox
5.Restart Apache.

沒有留言: