The JavaScript code in page.evaluate()
is not executed. Maybe you need to set the delay before performing?
var page = require("webpage").create(),
system = require("system"),
urls = "http://www.domaines.com",
useragents = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36",
w = 600,
h = 800,
cookie = phantom.addCookie({
'name' : 'uhash',
'value' : '8bb0c9ebcb5781g55196a1ff08c41b4d',
'domain' : '.domaines.com',
'path' : '/',
'httponly' : false,
'secure' : false
});
page.viewportSize = { width: w, height: h };
page.settings.userAgent = useragents;
page.open(urls, function(status){
if(status !=='success'){
phantom.exit();
}else{
page.cookie;
page.evaluate(function(){
function load(){
var links = document.querySelectorAll('a.link');
Array.prototype.forEach.call(links, function(e){
e.click();
});
}
document.addEventListener('DOMContentLoaded', load);
});
window.setTimeout(function () {
page.render('s.png');
phantom.exit();
}, 200);
}
});