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頁面