page.clipRect导致page.render()挂
问题描述:
我有这个脚本截屏与PhantomJS:page.clipRect导致page.render()挂
var page = require('webpage').create();
page.open('https://github.com', function() {
page.viewportSize = { width: 320, height: 600 };
page.render('e:\\Screenshots\\test.png');
phantom.exit();
它工作正常,但我想设置的视口的高度,因为它是目前整个页面高度。
文档说使用page.clipRect:http://phantomjs.org/screen-capture.html
但是,下面的代码不能正常工作,它只是挂起,从不截图:
var page = require('webpage').create();
page.open('https://github.com', function() {
page.viewportSize = { width: 320, height: 600 };
page.clipRect = { top: 0, left: 0, width: 320 height: 600 };
page.render('e:\\Screenshots\\test.png');
phantom.exit();
我没有得到任何错误,只是没有发生并输入摊位。
任何想法是怎么回事?
答
只是一个普通的老错字:
page.clipRect = { top: 0, left: 0, width: 320 height: 600 };
应该
page.clipRect = { top: 0, left: 0, width: 320, height: 600 };
^
但为什么会PhantomJS只是挂在那里默默?在v2中有一个错误,因为它不会显示错误,所以现在我使用v1.9.8来查找语法错误。
啊啊谢谢,不敢相信我没注意到。 1.9.8的好消息,我从现在开始也会这样做。 – Guerrilla