Created
September 1, 2015 05:54
-
-
Save japanetfutan/da63b9a4fac2902732c6 to your computer and use it in GitHub Desktop.
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 | |
echo -e "Content-type: text/plain;charset=UTF-8\n\n" | |
logfile=/home/public/ingresslog/$(date +%Y%m%d).html | |
yesterdayfile=/home/public/ingresslog/$(date +%Y%m%d -d '1 days ago').html | |
#初めて作るファイルはcss呼び出し付ける | |
if [ ! -f $logfile ]; then | |
cat <<EOF > $logfile | |
<link href="http://www.ingress.com/css/style_full.css" rel="stylesheet" type="text/css"> | |
<link href="http://www.ingress.com/css/common.css" rel="stylesheet" type="text/css"> | |
<link href="ingresslog.css" rel="stylesheet" type="text/css"> | |
EOF | |
fi | |
nowhour=$(date +%H) | |
#標準入力からログ書き込み | |
{ | |
while read line | |
do | |
wrk=$(echo "$line" | sed -re 's/ (ontouchstart|onclick)="[^"]+"//g' -e 's/<div class="plext">/<\/div><div class="plext">/' -e 's/(pl_portal_address">.*<\/span>)/\1<\/div>/') | |
loghour=$(echo "$line" | sed -re 's/.*>([0-9]+):.*/\1/') | |
if [ "$nowhour" -lt "$loghour" ]; then #ログの方が未来の場合、昨日のログに書く | |
echo "$wrk" >>$yesterdayfile | |
continue | |
fi | |
echo "$wrk" >> $logfile | |
done | |
} | |
if [ $? -eq 1 ];then | |
echo "write error!!!" | |
exit | |
fi | |
echo "$logfile write done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment