I am new in node. I have written a code using Node and Phantom to scrape a website. My code is working for google.com but not working for facebook because it is internally making an ajax request to other files to get the data.
var phantom = require('phantom');
phantom.create(function(ph) {
return ph.createPage(function(page) {
return page.open("https://facebook.com/", function(status) {
if(status !== 'success'){
console.log('Unable to load the url!');
ph.exit();
} else {
setTimeout(function() {
return page.evaluate(function() {
return document.getElementsByTagName('body')[0].innerHTML;
}, function(result) {
console.log(result); //Log out the data.
ph.exit();
});
}, 5000);
};
});
});
});
So basically when I am executing my code then in case of facebook it is returning unable to load but but in case of google it is giving body response.
Can anybody tell me what changes should I do to get the result?
PhantomJS version: 1.9.0