Last active
January 31, 2019 15:13
-
-
Save shyoshyo/0278a8df10d404b27ebdad471329f811 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
#!/usr/bin/env sh | |
INFO_USERNAME=... | |
INFO_PASSWORD=... | |
email=... | |
cookies="$(mktemp /tmp/cookie.XXXXXXXX)" | |
transcript_html="$(mktemp /tmp/transcript_html.XXXXXXXX)" | |
while true; do | |
echo "try.." | |
curl -L 'https://zhjw.cic.tsinghua.edu.cn/j_acegi_login.do?url=/portal3rd.do&m=bks_yxkccj&'$(curl -L -e '; auto' -c $cookies -sS -X POST https://info.tsinghua.edu.cn/Login -d "userName="$INFO_USERNAME"&password="$INFO_PASSWORD | grep -E "ticket=[^\"]+" -o | head -n 1) -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'Referer: https://info.tsinghua.edu.cn/render.userLayoutRootNode.uP' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,ja;q=0.6' --compressed -c $cookies -o $transcript_html --silent | |
if grep "/jxpgcicmain.do?m=index" $transcript_html > /dev/null; then | |
if ! grep -F "***" $transcript_html > /dev/null; then | |
break | |
fi | |
fi | |
curl -L 'https://zhjw.cic.tsinghua.edu.cn/j_acegi_login.do?url=/portal3rd.do&m=yjs_yxkccj&'$(curl -L -e '; auto' -c $cookies -sS -X POST https://info.tsinghua.edu.cn/Login -d "userName="$INFO_USERNAME"&password="$INFO_PASSWORD | grep -E "ticket=[^\"]+" -o | head -n 1) -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'Referer: https://info.tsinghua.edu.cn/render.userLayoutRootNode.uP' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,ja;q=0.6' --compressed -c $cookies -o $transcript_html --silent | |
if grep "/jxpgcicmain.do?m=index" $transcript_html > /dev/null; then | |
if ! grep -F "***" $transcript_html > /dev/null; then | |
break | |
fi | |
fi | |
done | |
cat $transcript_html | iconv -f gbk -t utf8 | sed -E 's/<a id=\"kcmur.+\);"//g' | sed -E 's/onMouseOver.+名 :<\/td><td>//g' | sed -E "s/<\/td><\/tr><tr><td align=right>学年学.+OPUP\);\"//g" | sed -E 's/onMouseOut="return nd\(\);"> <scri.+ript>/<a>/g' | sendemail -s mails.tsinghua.edu.cn -f $INFO_USERNAME"@mails.tsinghua.edu.cn" -t $email -u "new grade @ "$(date) -xu $INFO_USERNAME"@mails.tsinghua.edu.cn" -xp $INFO_PASSWORD -o tls=auto | |
rm $cookies $transcript_html | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment