I am trying to capture a specific website div on a screenshot to facilitate the work I have to do. So far I'm using this code, which I found on the same site that kinda works :
var page = require('webpage').create();
page.open('http://www.example.org', function() {
page.viewportSize = { width: 1440, height: 900 };
var clipRect = page.evaluate(function(){
return document.querySelector("div.example").getBoundingClientRect();
});
page.clipRect = {
top: clipRect.top,
left: clipRect.left,
width: clipRect.width,
height: clipRect.height
};
page.render('google.png');
phantom.exit();
});
This really works, but I have 2 problems:
1) The overlay is displayed on the first page, a pop-up window that appears in the screenshot. 2) Images are obviously loading because they need to be displayed (they only appear when scrolling on a web page).
So finally, I get something like this:
problem
phantomjs, , . DIV , , , , .
!