Reputation:
Hi i am working with PhantomJs to capture screen from url. But it seem sresult not accurate.
version of PhantomJS : 1.9.8, Operating system : Ubuntu 14
With this below code i tried to capture screen from a url but it seems its not giving perfect screen shot.. Or i am doing something wrong ?
See on header part of this website and screen shot..both are not similar.
Result screen shot : http://www.awesomescreenshot.com/image/2275399/7cf995d2e287cb87c4ca4895b6b69934
Website which i am trying to capture: http://www.whiteboardexplainers.com/
var system = require("system");
if (system.args.length > 0) {
var page = require('webpage').create();
page.viewportSize = {width: 1280, height: 1024};
page.open(system.args[1], function() {
var pageTitle = system.args[1].replace(/http.*\/\//g, "").replace("www.", "").split("/")[0]
var filePath = "pageTitle + '.png';
window.setTimeout(function () {
page.evaluate(function() {
document.body.bgColor = 'white';
});
page.render(filePath);
console.log(filePath);
phantom.exit();
}, 200);
});
}
Upvotes: 0
Views: 417
Reputation: 16838
You use a very outdated PhantomJS version. Considering that, screnshot looks very good. Upgrade to a modern PhantomJS version: 2.1.1 or even better 2.5 beta. Get them here: PhantomJS downloads archive.
But even a modern version does not support showing videos, so that will not work anyway.
In your case it does not seem relevant but often is: it is advisable to declare a useragent string of a modern browser. Otherwise many sites show a mobile version of their pages.
Upvotes: 1