- 檔案系統模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 系統模組
- PhantomJS - 屬性
- Web 伺服器模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 其他
- 命令列介面
- PhantomJS - 螢幕捕獲
- PhantomJS - 頁面自動化
- PhantomJS - 網路監控
- PhantomJS - 測試
- PhantomJS - REPL
- PhantomJS - 示例
- PhantomJS 有用資源
- PhantomJS - 快速指南
- PhantomJS - 有用資源
- PhantomJS - 討論
PhantomJS - clipRect 屬性
clipRect 是一個物件,其值包括頂部、左側、寬度和高度,並且在 render() 方法使用時用於獲取網頁的影像捕獲。如果未定義 clipRect,則在呼叫渲染方法時,它將獲取整個網頁的螢幕截圖。
語法
其語法如下 −
var page = require('webpage').create();
page.clipRect = {
top: 14,
left: 3,
width: 400,
height: 300
};
示例
請看以下示例以理解 clipRect 屬性的用法。
var wpage = require('webpage').create();
wpage.viewportSize = {
width: 1024,
height: 768
};
wpage.clipRect = {
top: 0,
left: 0,
width: 500,
height: 500
};
//the clipRect is the portion of the page you are taking a screenshot
wpage.open('http://www.google.com/', function() {
wpage.render('e.png');
phantom.exit();
});
在此,我們獲取網站 google.com 的螢幕截圖。它將生成以下 輸出 −
phantomjs_webpage_module_properties.htm
廣告