phantomjs 从字符串渲染页面
phantomjs to render a page from a string
我想从字符串呈现网页。我查看了 phantomjs 的文档,他们提出了以下建议:
var webPage = require('webpage');
var page = webPage.create();
var expectedContent = '<html><body><div>Test div</div></body></html>';
var expectedLocation = 'http://www.phantomjs.org/';
page.setContent(expectedContent, expectedLocation);
不太行得通。为什么? (我用的是最新版)[=11=]
我建议你呈现一个普通页面(about:blank
有效)然后做 webPage.content='<html><body><div>Test div</div></body></html>';
然后呈现您的页面。
希望对您有所帮助。
我想从字符串呈现网页。我查看了 phantomjs 的文档,他们提出了以下建议:
var webPage = require('webpage');
var page = webPage.create();
var expectedContent = '<html><body><div>Test div</div></body></html>';
var expectedLocation = 'http://www.phantomjs.org/';
page.setContent(expectedContent, expectedLocation);
不太行得通。为什么? (我用的是最新版)[=11=]
我建议你呈现一个普通页面(about:blank
有效)然后做 webPage.content='<html><body><div>Test div</div></body></html>';
然后呈现您的页面。
希望对您有所帮助。