我的页面中有一个脚本标签,但它没有运行。它被简单地渲染。
我有以下代码:
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)
另外,内容是"<p>Page <strong>1</strong> content.</p><button id=\"page1_button\">button</button><script>document.getElementsByTagName('p').innerHTML = 'test';</script>"