最近挂pt站,发现一段时间不登录,他就会封帐号。
所以考虑能不能写个脚本自动签到一下。
首先,chrome抓包url,在控制台右击,拷贝curl指令。
然后写个脚本自动跑一下这个curl指令。
再把这个指令丢进crontab,每天定时自动跑。
# cat sign.sh
#!/usr/bin
DATE=$(date +%Y%m%d%H%M%S)
echo $DATE >> sign.log
#签到
cm=$(curl 'https://pt.gztown.net/attendance.php' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 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://pt.gztown.net/details.php?id=1096&hit=1' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8' -H 'Cookie: xxxx' --compressed)
ret=$(echo $cm)
result=$(echo $ret | grep "您今天已经签到过了,请勿重复刷")
if [[ "$result" != "" ]];then
echo "签到港知堂 成功">> sign.log
else
echo "签到港知堂 失败">> sign.log
fi
#签到cmct
cm=$(curl 'https://hdcmct.org/usercp.php' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8' -H 'Cookie:xxxx' --compressed)
ret=$(echo $cm)
result=$(echo $ret | grep "加入日期")
if [[ "$result" != "" ]];then
echo "签到cmct 成功">> sign.log
else
echo "签到cmct 失败">> sign.log
fi
#签到hdcity
cm=$(curl 'https://hdcity.leniter.org/sign' -H 'Accept-Encoding: gzip' -H 'authority: hdcity.leniter.org' -H 'pragma: no-cache' -H 'cache-control: no-cache' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 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://hdcity.leniter.org/' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: zh-CN,zh;q=0.9,en;q=0.8' -H 'cookie: xxxx' --compressed)
ret=$(echo $cm)
result=$(echo $ret | grep "已签到")
if [[ "$result" != "" ]];then
echo "签到hdcity 成功" >> sign.log
else
echo "签到hdcity 失败">> sign.log
fi
cookie失效了,就自己重新生成一下curl命令。
关于crontab
#查看状态
service crond status
service crond start
service crond stop
service crond restart
service crond reload
ps -ef|grep cron
查看列表
crontab -l
文件目录 /var/spool/cron/
例子:
#php api every hour
0 * * * * php /var/www/html/Projects/Script/Hours.php
#php api every day
0 0 * * * php /var/www/html/Projects/Script/Days.php
#php api every month
0 0 1 * * php /var/www/html/Projects/Script/Months.php
#php api every week
0 0 * * 0 php /var/www/html/Projects/Script/Weeks.php
#php api every year
0 0 1 1 * php /var/www/html/Projects/Script/Years.php