1
我在页面内有一个脚本标记,但它没有运行。它只是呈现。我怎样才能得到幻影“执行”我的网页?
我有以下代码:
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);
});
});
我如何告诉幻影“装入” /“运行”的页面,使页面上运行脚本? (我不希望使用page.open)
此外,内容"<p>Page <strong>1</strong> content.</p><button id=\"page1_button\">button</button><script>document.getElementsByTagName('p').innerHTML = 'test';</script>"
对,问题是我不想在我想要在本地呈现文档时发出请求。有没有另一种方式? – Nonconformist
如果你绝对必须做任何你想做的事情,你可以使用网络服务器模块。 – kanzure