Last active
August 14, 2017 20:22
-
-
Save ysaotome/d14710539ad6a576f3dc to your computer and use it in GitHub Desktop.
バッチ処理でURL一覧ファイルから順次Chroniumでのレンダリング結果をキャプチャして保存していくスクリプト(サムネイル作成機能付き)
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
#!/bin/bash | |
LOGS_DIR='/var/www/html/logs' | |
THUMBNAIL_BIG_DIR='/var/www/html/thumbnail_big' | |
THUMBNAIL_SMALL_DIR='/var/www/html/thumbnail_small' | |
SCREEN_NUM=${2} | |
for i in `awk '{print $1}' < $1` | |
do | |
arr=(`echo $i | tr -s ',' ' '`) | |
URL=${arr[0]} | |
NAME=${arr[1]} | |
DATE=`date +%Y%m%d%H%M` | |
echo "URL:${URL} OUTPUT:${THUMBNAIL_BIG_DIR}/${DATE}_${URL}_${NAME}.jpg" | |
$( /usr/bin/timeout 60 /usr/bin/xvfb-run --server-args="-screen ${SCREEN_NUM}, 1024x768x24" /usr/bin/CutyCapt --url=${URL} --delay=2000 --out=${THUMBNAIL_BIG_DIR}/${DATE}_${URL}_${NAME}.jpg) | |
$( cp -pr ${THUMBNAIL_BIG_DIR}/${DATE}_${URL}_${NAME}.jpg ${THUMBNAIL_SMALL_DIR}/${DATE}_${URL}_${NAME}.jpg ) | |
$( /usr/bin/mogrify -resize 40% -quality 80 -verbose ${THUMBNAIL_SMALL_DIR}/${DATE}_${URL}_${NAME}.jpg ) | |
done | tee -a ${LOGS_DIR}/capt_`date +%Y%m%d%H%M`.log |
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
使い方 | |
./capture.sh <URLリストファイル> <画面番号> | |
使い方例 | |
シングルスレッド | |
./capture.sh urlA.list 0 | |
マルチスレッド | |
./capture.sh urlA.list 0 & | |
./capture.sh urlB.list 1 & | |
実行に必要なパケージ(CentOS 6.5 x86_64) | |
yum --enablerepo=rpmforge,epel,remi install CutyCapt xorg-x11-server-Xvfb.x86_64 ImageMagick-last.x86_64 |
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
http://www.google.com,Google | |
http://www.nifty.com,@nifty | |
http://www.yahoo.co.jp,Yahoo! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment