写一个脚本,每天 定时自动签到 PT 站。

{% note warning %}

加了 图片验证的比较复杂,目前搞不定,只对不需要 验证码的签到有效。

{% endnote %}

第一版

脚本如下,自己需要修改 cookie ,或者其他。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
# author: rachpt
echo "hyperay 签到"
curl 'https://www.hyperay.org/sign_in.php' \
-H 'Host: www.hyperay.org' \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0' \
-H 'Accept: */*' \
-H 'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2' --compressed \
-H 'Content-type: application/x-www-form-urlencoded' \
-H 'Cookie: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'DNT: 1' \
-H 'Connection: keep-alive' \
--data 'action=sign_in'

echo ''
echo "hdhome 签到"
echo ''

curl 'https://hdhome.org/attendance.php' \
-H 'Host: hdhome.org' \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
-H 'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2' --compressed \
-H 'Cookie: __xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'DNT: 1' \
-H 'Connection: keep-alive' \
-H 'Upgrade-Insecure-Requests: 1'

echo ''
echo "6v 签到"
echo ''

curl 'http://bt.neu6.edu.cn/forum.php' \
-H 'Host: bt.neu6.edu.cn' \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
-H 'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2' --compressed \
-H 'Cookie: LRpW_2132_ulastactivity=fb5dVHpNQ0vxxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'DNT: 1' \
-H 'Connection: keep-alive' \
-H 'Upgrade-Insecure-Requests: 1'

echo ''
echo "hdchina 签到"
echo ''

curl 'https://hdchina.org/plugin_sign-in.php?cmd=signin' \
-H 'Host: hdchina.org' \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0' \
-H 'Accept: */*' \
-H 'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2' --compressed \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Cookie: __cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'DNT: 1' \
-H 'Connection: keep-alive' \
--data 'cmd=signin'

echo ''
echo "TTG 签到"
echo ''

tempPage=`mktemp ttgpage.XXXXXX`

curl 'https://totheglory.im/' \
-H 'Host: totheglory.im' \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0' \
-H 'Accept: */*' \
-H 'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2' --compressed \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Cookie: __xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'DNT: 1' \
-H 'Connection: keep-alive' > $tempPage

myTimestamp=`gawk '/token/{print $3}' $tempPage | gawk 'BEGIN{FS="\""} {print $2}'`

myToken=`gawk '/token/{print $5}' $tempPage | gawk 'BEGIN{FS="\""} {print $2}'`

curl 'https://totheglory.im/signed.php' \
-H 'Host: totheglory.im' \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0' \
-H 'Accept: */*' \
-H 'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2' --compressed \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Cookie: __xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'DNT: 1' \
-H 'Connection: keep-alive' \
--data 'signed_timestamp=$myTimestamp&signed_token=$myToken'

rm -f $tempPage


echo ''
echo "所有签到完成!"

exit

其中 TTG 和其他的有区别,需要获取 但前时间 time 以及 token,比较懒,curl 的头可以封装 成函数,这里 直接 使用 firefox 复制的 curl 链接。😂 😂 😂

firefox-debug-1.jpg

定时 任务 请参考 here , and here

第二版

添加 cmct.tv ,TTG 的需要修改 cookie 格式,以及变量存在的行使用 双引号!

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
# author: rachpt
echo "hyperay 签到"
curl 'https://www.hyperay.org/sign_in.php' \
-H 'Host: www.hyperay.org' \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0' \
-H 'Accept: */*' \
-H 'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2' --compressed \
-H 'Content-type: application/x-www-form-urlencoded' \
-H 'Cookie: xxxxxxxxxxxxxx'  \
-H 'DNT: 1' \
-H 'Connection: keep-alive' \
--data 'action=sign_in'

echo ''
echo "hdhome 签到"
echo ''

curl 'https://hdhome.org/attendance.php' \
-H 'Host: hdhome.org' \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
-H 'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2' --compressed \
-H 'Cookie: xxxxxxxxxxxxxx'  \
-H 'DNT: 1' \
-H 'Connection: keep-alive' \
-H 'Upgrade-Insecure-Requests: 1'

echo ''
echo "6v 签到"
echo ''

curl 'http://bt.neu6.edu.cn/forum.php' \
-H 'Host: bt.neu6.edu.cn' \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
-H 'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2' --compressed \
-H 'Cookie: xxxxxxxxxxxxxx'  \
-H 'DNT: 1' \
-H 'Connection: keep-alive' \
-H 'Upgrade-Insecure-Requests: 1'

echo ''
echo "hdchina 签到"
echo ''

curl 'https://hdchina.org/plugin_sign-in.php?cmd=signin' \
-H 'Host: hdchina.org' \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0' \
-H 'Accept: */*' \
-H 'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2' --compressed \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Cookie: xxxxxxxxxxxxxx'  \
-H 'DNT: 1' \
-H 'Connection: keep-alive' \
--data 'cmd=signin'

echo ''
echo "TTG 签到"
echo ''

tempPage=`mktemp ttgpage.XXXXXX`
### 获取 cookie
curl  -c ttgcookie 'https://totheglory.im/' \
-H 'Host: totheglory.im' \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0' \
-H 'Accept: */*' \
-H 'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2' --compressed \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Cookie: __cfduid=xxxxxxxxxxxxxx; uid=XXXXXX; pass=xxxxxxxx' \
-H 'DNT: 1' \
-H 'Connection: keep-alive' > $tempPage

# myTimestamp=`gawk '/token/{print $3}' $tempPage | gawk 'BEGIN{FS="\""} {print $2}'`
# 不需要上面这个!
myToken=`gawk '/token/{print $5}' $tempPage | gawk 'BEGIN{FS="\""} {print $2}'`

myLaccess=`cat "ttgcookie" | awk '/laccess/{print $7}'`

curl 'https://totheglory.im/signed.php' \
-H 'Host: totheglory.im' \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0' \
-H 'Accept: */*' \
-H 'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2' --compressed \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'X-Requested-With: XMLHttpRequest' \
-H "Cookie: __cfduid=xxxxxxxxxxxxxx; uid=XXXXXX'; pass=xxxxxxxx" \
-H 'DNT: 1' \
-H 'Connection: keep-alive' \
--data "signed_timestamp=$myLaccess&signed_token=$myToken"
# 注意 使用了变量的地方 使用 双引号 不能使用 单引号。
rm -f $tempPage ttgcookie

echo ''
echo "CMCT.tv 签到"
echo ''

curl 'https://cmct.tv/plugin.php?id=dsu_paulsign:sign&operation=qiandao&infloat=1&inajax=1' \
-H 'Host: cmct.tv' \
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0' \
-H 'Accept: */*' \
-H 'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2' --compressed \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Cookie: xxxxxxxxxxxxxx'  \
-H 'DNT: 1' \
-H 'Connection: keep-alive' \
--data 'formhash=04fcd2f6&qdxq=ym&qdmode=1&todaysay=%C7%A9%B5%BD%C0%B2%C0%B2%C0%B2%A1%A3%A1%A3%A1%A3&fastreply=0'


echo ''
echo "所有签到完成!"

exit

注意 使用了变量的地方 使用 双引号 不能使用 单引号。TTG cookie 中的 PHPSESSID 字段 不需要。

更新(使用 httpie)

需要安装 httpie,curl 处理 ttg 不是很方便。

脚本需要自己比对 修改 cookie。

http 在crontab 中运行需要添加 --ignore-stdin

2018.11.19

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# author: rachpt

#-----------------------------------------------#
echo '-------------------------'
echo "[hyperay 签到]"
echo ''

cookie_hyperay='Cookie: c_secure_uid=XXXXXX==; c_secure_pass=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxa; c_secure_login=bm9wZQ=='

http --ignore-stdin -b -f POST 'https://www.hyperay.org/sign_in.php' action=sign_in "$cookie_hyperay"|grep --color=never '.*'

#-----------------------------------------------#
echo '-------------------------'
echo "[hdhome 签到]"
echo ''

cookie_hdhome='Cookie: c_secure_uid=XXXXXXX=; c_secure_pass=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; c_secure_login=bm9wZQ=='

http --ignore-stdin -b GET 'https://hdhome.org/attendance.php' "$cookie_hdhome"|grep -A 10 '"outer"'|grep 'table width='|sed -r 's/<[^>]+>//ig'

#-----------------------------------------------#
echo '-------------------------'
echo "[TTG 签到]"
echo ''

cookie_ttg='Cookie: uid=000000; pass=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; PHPSESSID=xxxxxxxxxxxxxxxxxxxxxxxxxx'

http --ignore-stdin -b GET 'https://totheglory.im/' "$cookie_ttg" > /dev/null
# 如果提示[未能获取到 Token!],则需要更换下面一行的请求链接!
ttg_post_data="$(http --ignore-stdin -b GET 'https://totheglory.im/disclaimer.php' "$cookie_ttg"|grep 'signed_timestamp')"

ttg_timestamp="$(echo "$ttg_post_data"|awk '{print $3}'|sed 's/[\" ,{}]//g')"

ttg_token="$(echo "$ttg_post_data"|awk '{print $5}'|sed 's/[\" ,{}]//g')"

http --ignore-stdin -b -f POST 'https://totheglory.im/signed.php' signed_timestamp=$ttg_timestamp signed_token=$ttg_token "$cookie_ttg"|grep '.*'
echo -e "\n当前状态:\c"
if [ ! "$ttg_token" ]; then 
    echo '[未能获取到 Token!]'
else
    http --ignore-stdin -b GET 'https://totheglory.im/disclaimer.php' "$cookie_ttg"|grep '"sp_signed"'|sed -r 's/\[<a.*donate.php.*a>\]//;s/<[^>]+>//ig;s/ //g;s/&nbsp;//g'
fi

#-----------------------------------------------#
echo '-------------------------'
echo "[hdchina 签到]"
echo ''

cookie_hdchina='Cookie: mv_secure_uid=XXXXXXXX; mv_secure_pass=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; mv_secure_login=bm9wZQ=='

http --ignore-stdin -b -f POST 'https://hdchina.org/plugin_sign-in.php?cmd=signin' cmd=signin "$cookie_hdchina"|grep 'state'

#-----------------------------------------------#
echo '-------------------------'
echo "[所有签到完成!]"

pt-qiandao-1.jpg

pt-qiandao-2.jpg