Last active
January 21, 2020 22:21
-
-
Save hagino3000/5762896 to your computer and use it in GitHub Desktop.
Capture screenshot using phantom.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = new WebPage(), | |
address, output, size; | |
if (phantom.args.length != 2) { | |
console.log('Give me URL and filename'); | |
phantom.exit(); | |
} else { | |
address = phantom.args[0]; | |
output = phantom.args[1]; | |
page.viewportSize = { width: 1024, height: 768 }; | |
page.open(address, function (status) { | |
if (status !== 'success') { | |
console.log('Unable to load the address!'); | |
} else { | |
setTimeout(function() { | |
page.render(output); | |
phantom.exit(); | |
}, 1000); | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
phantomjs capture.js http://www.yahoo.co.jp yahoo.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment