Last active
August 29, 2015 14:01
-
-
Save pronto/dc37f6364b2e60c8c28e to your computer and use it in GitHub Desktop.
zsh script to call phantomjs screenshot
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
#!/usr/local/bin/zsh | |
if [[ -z $1 ]]; then | |
echo 'syntax: shootphantom URL [name] (.png will be added for you)' | |
echo 'if NAME is empty a name will be attempted to be guessed' | |
return 1 | |
fi | |
DATE=`date +%s` | |
URL=$1 | |
echo 'url is:' $URL | |
if [[ ! -z $2 ]];then | |
echo 'using provided name' | |
NAME=$2.$DATE | |
else | |
echo 'using guessed name' | |
URL_SPLIT=("${(s./.)URL}") | |
if [[ "${#URL_SPLIT[-1]}" == 0 ]];then | |
if [[ "$URL_SPLIT[-1]" == "$URL_SPLIT[2]" ]];then | |
ENDPART='index' | |
else | |
ENDPART=$URL_SPLIT[-2] | |
fi | |
else | |
ENDPART=$URL_SPLIT[-1] | |
echo 'wut' | |
fi | |
if [[ "$ENDPART" == "$URL_SPLIT[2]" ]];then | |
ENDPART='index' | |
fi | |
NAME=$URL_SPLIT[2].$ENDPART.$DATE | |
fi | |
NAME=$NAME | |
echo $NAME | |
phantomjs /home/pronto/bin/shootphantom.js $URL $NAME | |
echo "http://freebsd.crackthat.pw/a/screens/$NAME.png" |
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 = require('webpage').create(); | |
page.settings.userAgent='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36'; | |
page.viewportSize = {height:1300, width: 1300 }; | |
var url = phantom.args[0] | |
var name = phantom.args[1] | |
page.open(url, function() { | |
page.render('/usr/home/pronto/www/screens/'+name+'.png'); | |
phantom.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment