sgentle/phantomjs-node — Issue #1: page.evaluate not parsing through html
Author: balthasar
Created: 2011-10-12 08:59:04+00:00
State: open

Hi,

I am trying to get page.evaluate working to pass through html once the page is loaded. The waiting part is working, ie it waits until the page has finished loading, but when trying to select the html portion of code to return I get 'null' back.

Phantomjs is installed correctly as this works in phantom but running through node I am getting these issues

Below is my code.

'''javascript

var phantom = require('phantom');

phantom.create(function(ph) {
return ph.createPage(function(page){
return page.open('http://home.safindit.co.za/places', function (status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
interval = setInterval(function() {
// Check in the page if a specific element is now hidden
return page.evaluate((function() {
return $("#status-container").is(":hidden");
}), function(result) {
if(!result){
console.log('still waiting...');
}
else{
console.log('Page Loaded');
return page.evaluate((function() {
return document.getElementById('view').innerHTML();
}), function(result) {
console.log(result);
clearInterval(interval)
return ph.exit();
});
}
});
}, 250); //< repeat check every 250ms
}
});
});
});
'''

Thanks in advance