How to screen capture a web page on the specified server #11209

Open
hujunya opened this Issue Apr 6, 2013 · 0 comments

1 participant

@hujunya

I want to screen capture a website page on one specified server in the cluster , and the website is not the default website on the server. So I should send the HTTP request with the HOST . I modified the /example/rasterize.js, like this:

/******************************************************/
var page = require('webpage').create(),
system = require('system'),
address, output, /
size*/host;

if (system.args.length < 3 || system.args.length > 5) {
console.log('Usage: rasterize.js URL filename [paperwidthpaperheight|paperformat] [zoom]');
console.log(' paper (pdf output) examples: "5in
7.5in", "10cm20cm", "A4", "Letter"');
phantom.exit(1);
} else {
address = system.args[1];
output = system.args[2];
host = system.args[3]
page.viewportSize = { width: 600, height: 600 };
/

if (system.args.length > 3 && system.args[2].substr(-4) === ".pdf") {
size = system.args[3].split('');
page.paperSize = size.length === 2 ? { width: size[0], height: size[1], margin: '0px' }
: { format: system.args[3], orientation: 'portrait', margin: '1cm' };
}
if (system.args.length > 4) {
page.zoomFactor = system.args[4];
}
*/
page.customHeader = {
'HOST':host
}
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
phantom.exit();
} else {
window.setTimeout(function () {
page.render(output);
phantom.exit();
}, 200);
}
});
}
/
******************************************************/

I use “ phantomjs rasterize.js http://192.168.*.*/index.aspx index.jpg www.mywebsite.com " to capture screen.

It now can screen capture the website page on the specified server. But it only capture the base page of the website. If the meta in the page is not on this server, it can not be captured.

So how can I capture the whole page with the "HOST:www.mywebsite.com" in the request ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment