Reputation: 39
I use phantomjs to screenshot a page,but can't screenshot buttom of the page.
var height = page.evaluate(function()
{
window.document.body.scrollTop = document.body.scrollHeight;
}
);
value of the height is 33943,but the real value of scrollHeight is 44135. how can I load the whole page?
Upvotes: 2
Views: 2381
Reputation: 99
I managed to took a screenshot of the whole page by setting the page property.
For example:
var width = 1024, height = 768;
page.property("viewportSize", {'width': width, 'height': height});
The one on the docs page.viewportSize = { width: 1024, height: 768 };
might not be updated because it returned the warning :
warn: Using page.viewportSize = ...; is not supported. Use page.property('viewportSize', ...) instead. See the README file for more examples of page#property.
Upvotes: 1
Reputation: 54212
You can snapshot your page by:
var WebPage = require('webpage');
page = WebPage.create();
page.open('http://www.example.com');
page.onLoadFinished = function() {
page.render('screenshot.png');
phantom.exit();
}
Not sure why you need to calculate the height of your page.
Upvotes: 1