我想使用 phantomjs 截取网页的屏幕截图,例如在 iphone 上呈现的网页。
我用这个:
page.settings.userAgent = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 6_0 like Mac OS X; en-us) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A523 Safari/8356.25';
page.viewportSize = { width: 320, height: 480 };
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
phantom.exit(2);
} else {
window.setTimeout(function () {
page.clipRect = { top: 0, left: 0, width: 320, height: 480 };
page.render(output);
phantom.exit(3);
}, 200);
}
});
但是好像没用...