page.set('content')不适用于phantomjs中的动态内容

Eri*_*rik 2 node.js phantomjs

我尝试使用phantomjs屏幕捕获我的页面节点 - 幻像桥.这是我正在尝试的:

 var phantom = require('node-phantom');

 phantom.create(function (err, ph) {
            return ph.createPage(function (err, page) {
              return page.set('content', '<html><head></head><body><p>Hello</p></body></html>', function (err, status) {
                  return page.render('./content.png', function (err) {
                    ph.exit();
                  });
                });
            });
          });
Run Code Online (Sandbox Code Playgroud)

这工作正常,但如果我尝试设置包含javascript的内容,那不起作用.请帮帮我,为什么不行?

编辑:这不起作用:

var phantom = require('node-phantom');

phantom.create(function (err, ph) {
   return ph.createPage(function (err, page) {
      page.open("about:blank", function(err,status) {
         page.evaluate(function() {        
            document.write('<html><head></head><body><script src="http://code.jquery.com/jquery-1.9.1.min.js"></script><script>$(function(){document.write("Hello from jQuery")})</script></body>');
         });

         setTimeout(function () {
            return page.render('./content.png', function (err) {
                ph.exit();
             }); 
         }, 5000);   
    });         
  });
Run Code Online (Sandbox Code Playgroud)

Ari*_*yat 5

JavaScript代码需要一些时间来执行.尝试在设置页面内容和调用之间有一个延迟render.