指点天下Python签到脚本

警告
本文最后更新于 2018-12-23,文中内容可能已过时。

学校每天晚上让用一个垃圾app签到就寝,没办法,写了个脚本来解放双手。

抓手机app的签到包

 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# author:Y4er

import requests
import json
import hashlib

def getToken(phone,password):
	url = 'http://app.zhidiantianxia.cn/api/Login/pwd'
	headers = {
	'Host': 'app.zhidiantianxia.cn',
	'Content-Type': 'application/x-www-form-urlencoded',
	'User-Agent': 'okhttp/3.10.0'
	}
	params = {
		'phone': phone,
		'password': password,
		'mobileSystem': '8.1.0',
		'appVersion': '1.1.4',
		'mobileVersion': 'MI 6X',
		'deviceToken': '1507bfd3f7ec78ab60e'
	}
	token = requests.post(url,params=params,headers=headers).json()['data']
	return token

def qianDao(phone,token):
	url = 'http://zzrvtc.zhidiantianxia.cn/applets/signin/sign'
	headers = {
		'axy-phone': phone,
		'axy-token': token,
		'Content-Type': 'application/json',
		'user-agent': 'MI 6X(Android/8.1.0) (com.axy.zhidian/1.1.4) Weex/0.18.0 1080x2030',
		'Host': 'zzrvtc.zhidiantianxia.cn'
	}
	payload = {"lat":"34.794349","lng":"113.887287","signInId":1562}
	res = requests.post(url,headers=headers,data=json.dumps(payload)).json()['msg']
	print("手机号:{0} 签到结果:{1}".format(phone,res))

def getPhoneAndPass():
	results = []
	with open('password.txt','r',encoding='utf-8') as f:
		for line in f.readlines():
			line = line.strip('\n')
			phone = line.split('|')[0]
			password = line.split('|')[1]
			m = hashlib.md5()
			m.update(b"axy_" + bytes(password,encoding = "utf8"))
			password = m.hexdigest()
			results.append([phone,password])
		f.close()
	return results

if __name__ == '__main__':

	results = getPhoneAndPass()
	for phone,password in results:
		token = getToken(phone, password)
		qianDao(phone,token)

因为前天搞得签到需要自行获取signInId,这次更新了下,直接代码获取

 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# author:Y4er

import requests
import json
import hashlib
import smtplib
from email.mime.text import MIMEText
from email.header import Header

def mailTome():
	# 第三方 SMTP 服务
	mail_host="smtp.ym.163.com"  #设置服务器
	mail_user="[email protected]"    #用户名
	mail_pass="smtppassword"   #口令 
	sender = '[email protected]'
	receivers = ['[email protected]']  # 接收邮件,可设置为你的QQ邮箱或者其他邮箱
	message = MIMEText('指点天下签到完毕,请自行查看结果', 'plain', 'utf-8')
	message['From'] = Header("[email protected]", 'utf-8')
	message['To'] =  Header("指点天下签到完毕,请自行查看结果", 'utf-8')
	subject = '指点天下签到完毕,请自行查看结果'
	message['Subject'] = Header(subject, 'utf-8')
	try:
	    smtpObj = smtplib.SMTP() 
	    smtpObj.connect(mail_host, 25)    # 25 为 SMTP 端口号
	    smtpObj.login(mail_user,mail_pass)
	    smtpObj.sendmail(sender, receivers, message.as_string())
	    print ("邮件发送成功")
	except smtplib.SMTPException:
	    print ("Error: 无法发送邮件")

def getToken(phone,password):
	url = 'http://app.zhidiantianxia.cn/api/Login/pwd'
	headers = {
	'Host': 'app.zhidiantianxia.cn',
	'Content-Type': 'application/x-www-form-urlencoded',
	'User-Agent': 'okhttp/3.10.0'
	}
	params = {
		'phone': phone,
		'password': password,
		'mobileSystem': '8.1.0',
		'appVersion': '1.1.4',
		'mobileVersion': 'MI 6X',
		'deviceToken': '1507bfd3f7ec78ab60e'
	}
	token = requests.post(url,params=params,headers=headers).json()['data']
	return token

def getsignInId(phone,token):
	url = 'http://zzrvtc.zhidiantianxia.cn/applets/signin/my'
	headers = {
		'axy-phone': phone,
		'axy-token': token,
		'user-agent': 'MI 6X(Android/8.1.0) (com.axy.zhidian/1.1.4) Weex/0.18.0 1080x2030',
		'Host': 'zzrvtc.zhidiantianxia.cn'
	}
	params = {
		'page': '0',
		'size': '10'
	}
	signInId = requests.get(url,headers=headers,params=params).json()['data']['content'][0]['id']
	return signInId

def qianDao(phone,token):
	url = 'http://zzrvtc.zhidiantianxia.cn/applets/signin/sign'
	headers = {
		'axy-phone': phone,
		'axy-token': token,
		'Content-Type': 'application/json',
		'user-agent': 'MI 6X(Android/8.1.0) (com.axy.zhidian/1.1.4) Weex/0.18.0 1080x2030',
		'Host': 'zzrvtc.zhidiantianxia.cn'
	}
	payload = {"lat":"34.794349","lng":"113.887287","signInId":getsignInId(phone,token)}
	res = requests.post(url,headers=headers,data=json.dumps(payload)).json()['msg']
	print("手机号:{0} 签到结果:{1}".format(phone,res))

def getPhoneAndPass():
	results = []
	with open('password.txt','r',encoding='utf-8') as f:
		for line in f.readlines():
			line = line.strip('\n')
			phone = line.split('|')[0]
			password = line.split('|')[1]
			m = hashlib.md5()
			m.update(b"axy_" + bytes(password,encoding = "utf8"))
			password = m.hexdigest()
			results.append([phone,password])
		f.close()
	return results

if __name__ == '__main__':
	results = getPhoneAndPass()
	for phone,password in results:
		token = getToken(phone, password)
		qianDao(phone,token)
	mailTome()