PhantomJS - setContent() 方法
setcontent 方法将使用指定的内容更改指定 URL 的页面内容。
语法
其语法如下 −
var wpage = require('webpage').create(); wpage.setContent(content, pageurl);
示例
以下示例显示了 setContent() 方法的使用。
var wpage = require('webpage').create(); var Content = '<html><body><div>Test div</div></body></html>'; var pageurl = 'http://localhost/tasks/c.html'; wpage.setContent(Content, pageurl); wpage.onLoadFinished = function(status) { wpage.render('newtest.png'); phantom.exit(); };
输出 – newtest.png
上述程序生成以下输出。

phantomjs_webpage_module_methods.html