Node.js 我怎样才能让幻影“到”;执行;我的页面?
我的页面中有一个脚本标记,但它没有运行。它只是简单地渲染 我有以下代码:Node.js 我怎样才能让幻影“到”;执行;我的页面?,node.js,express,phantomjs,Node.js,Express,Phantomjs,我的页面中有一个脚本标记,但它没有运行。它只是简单地渲染 我有以下代码: var phantom = require('phantom'); phantom.create(function(ph,error) { c = callback; ph.createPage(function( page,err ) { page.setContent( output ); callback = c; setTimeout(function() { pa
var phantom = require('phantom');
phantom.create(function(ph,error) {
c = callback;
ph.createPage(function( page,err ) {
page.setContent( output );
callback = c;
setTimeout(function() {
page.evaluate(function() {
return document.getElementsByTagName('html')[0].innerHTML;
}, function(html) {
callback(html);
});
}, 5000);
});
});
如何让phantom“加载”/“执行”页面,以便页面上的脚本运行?(我不想使用page.open)
另外,内容是
“页面1内容。按钮文档。getElementsByTagName('p')。innerHTML='test';”
调用页面。打开,请参阅以获取参数
第一个参数是url,第二个参数是回调
在页面的回调中。打开
,然后应调用页面。按照之前的尝试进行评估
page.open("http://httpbin.org/get", function(status) {
if (status == "success") {
page.evaluate(function() {
// ...
});
}
});
好的,问题是当我有我想要在本地呈现的文档时,我不想发出请求。还有其他方法吗?如果你必须做任何你想做的事情,你可以使用webserver模块。