更新时间:2023-02-24 13:50:39
由于您使用的是由Webkit浏览器构建的PhantomJS,因此可以访问本机JSON库.无需使用page.evaluate,您只需在页面对象上使用plainText属性即可.
Since you are using PhantomJS which is built of the webkit browser you have access to the native JSON library. There is no need to use page.evaluate, you can just use the plainText property on the page object.
http://phantomjs.org/api/webpage/property/plain-text.html
var page = require('webpage').create();
page.open('http://somejsonpage.com', function () {
var jsonSource = page.plainText;
var resultObject = JSON.parse(jsonSource);
phantom.exit();
});