我想保存代码中指定的 div 内部的图像。但使用下面的代码,我得到了其他部分的渲染结果。这是正确的做法吗?我只是一个初学者,希望得到帮助。
var page = require('webpage').create();
page.open("http://n1k0.github.io/casperjs/#phantom_Casper_captureSelector", function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
} else {
var clipRect = page.evaluate(function () {
return document.querySelector(".span7 demo").getBoundingClientRect(); });
page.clipRect = {
top: clipRect.top,
left: clipRect.left,
width: clipRect.width,
height: clipRect.height
};
window.setTimeout(function () {
page.render('capture.png');
phantom.exit();
}, 200);
}
});