0
我試圖使用webpage.open內部函數法的回調,但得到未定義的值:如何在函數返回中使用PhantomJS的webpage.open回調?
getPagesCount = function (url)
{
var page = require('webpage').create();
return page.open(url, function (status) {
if (status === 'success') {
return page.evaluate(function() {
return document.body.innerHTML;
});
}
});
}
html = getPagesCount('http://google.com');
console.log(html);
phantom.exit();
得到「未定義」。
dm03514,有唯一的辦法?我不能在getPagesCount基金之外使用var html嗎? – MaineKampfCoon