0
下面是phantomjs代码page.evaluate返回null文件
page.open('https://onli**************uickpay.html', function (status) {
if (status !== 'success') {
console.log('Unable to access network')
} else {
console.log('internet is working');
var ua = page.evaluate(function (loanID) {
var loanIDSplit = loanID.split('/');
document.getElementById("txtBranchCode").value = loanIDSplit[0];
document.getElementById("txtType").value = loanIDSplit[1];
document.getElementById("txtLoanNumber").value = loanIDSplit[2];
document.getElementById("btnLoanNoSearch").click();
}, loanID);
console.log(util.inspect(document, false, null));
setTimeout(function() {
var html = page.evaluate(function() {
var table = document.getElementById('tblQpLoanNo');
table.getElementsByClassName('odd')[0].click();
document.getElementById("LoNoPayButton").click();
return document;
});
page.render('/home/ubuntu/github.png');
console.log('is the value of document'+html);
}, 3000);
setTimeout(function(){
var release_amount = page.evaluate(function() {
var table = document.getElementById('tblQpPayment');
var row = table.getElementsByClassName('odd')[0];
var payableAmount = row.getElementsByTagName('td')[3].textContent;
return payableAmount;
});
console.log("release amount value is "+release_amount);
// system.stdout.write("$" + releaseAmount);
// system.stdout.write("$" + loanID);
phantom.exit();
}, 10000);
}
上面的代码和平运行时,时记录的是显示了HTML null值
它与phantomjs工程完美在macosx中,但是当我将它部署到Ubuntu服务器时,它不起作用。我确定我使用的是phantomjs,支持linux
第一页.evaluate工作正常,在下一页.evaluate在3秒后没有工作,我浪费了足够的时间进行调试并最终在这里询问,如果有人遇到同样的问题或者缺少某些信息,请亲自问我。
什么可以为文件是空的原因,那么这是指在评估html页面