Phantomjs拍摄iphone上渲染的网站截图

时间:2012-11-27 19:16:01

标签: javascript phantomjs

我想使用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);
    }
});

但似乎没有用......

0 个答案:

没有答案