【发布时间】:2013-09-06 12:13:16
【问题描述】:
我想将图像保存在代码中指定的 div 内。但是使用下面的代码,我正在渲染其他部分。这是正确的方法吗?我只是 phantomjs 的初学者。所以请帮忙。
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);
}
});
【问题讨论】:
-
它看起来很精简,快速搜索给你这个 SO 线程:stackoverflow.com/questions/11917042/…
-
@DanielFigueroa 感谢您的链接。我仍然无法在我的代码中找到错误。
-
实际上我正在渲染一部分。但从同一页面的其他部分裁剪。
标签: javascript phantomjs