- #!/bin/bash
- USERNAME="[email protected]"
- PWD="xxxxxxxxxxxxx"
- API_LOGIN_VALIDATE="http://www.oschina.net/action/api/login_validate"
- API_USER_NOTICE="http://www.oschina.net/action/api/user_notice"
- DATA_LOGIN=$(curl -d "username="$USERNAME"&pwd="$PWD"&keep_login=1" -c /tmp/osc.cookie $API_LOGIN_VALIDATE 2>&1)
- DATA_OSC_UID=$(echo "$DATA_LOGIN" | grep '<uid' | cut -f2 -d">"|cut -f1 -d"<")
- DATA_USER_NOTICE=$(curl -d "uid=$DATA_OSC_UID" -b /tmp/osc.cookie $API_USER_NOTICE 2>&1)
- atmeCount=$(echo "$DATA_USER_NOTICE" | grep '<atmeCount' | cut -f2 -d">"|cut -f1 -d"<")
- msgCount=$(echo "$DATA_USER_NOTICE" | grep '<msgCount' | cut -f2 -d">"|cut -f1 -d"<")
- reviewCount=$(echo "$DATA_USER_NOTICE" | grep '<reviewCount' | cut -f2 -d">"|cut -f1 -d"<")
- newFansCount=$(echo "$DATA_USER_NOTICE" | grep '<newFansCount' | cut -f2 -d">"|cut -f1 -d"<")
- if [ $atmeCount != "0" ] || [ $msgCount != "0" ] || [ $reviewCount != "0" ] || [ $newFansCount != "0" ]
- then
- notify-send "OSChina通知" "数据:$atmeCount / $msgCount / $reviewCount / $newFansCount"
- fi
来源: http://www.phpxs.com/code/1007467/