Wednesday, 14 August 2013

document.images creating a list where only the first element is valid

document.images creating a list where only the first element is valid

Have been tinkering away with phantomJS and have come across something i
dont understand. I can see the number of photos but can only see the first
object
var page = require('webpage').create(),
system = require('system'),
address = 'http://en.wikipedia.org/wiki/Tiger'
page.open(address,function(status){
page.render('page.png');
if(status=="success"){
var title = page.evaluate(function () {
return document.title;
});
console.log('Page title is ' + title);
var imgs = page.evaluate(function() {
return document.images;
});
console.log(imgs.length);
console.log(imgs[0]);
console.log(imgs[1]);
}
phantom.exit();
})
the output of this is:
Page title is Tiger - ....
95
[object Object]
null
Any idea why the only the 1st object is listed?

No comments:

Post a Comment