指点天下Python签到脚本

Share on:

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

思路

抓手机app的签到包

代码

 1#!/usr/bin/env python3
 2# -*- coding: utf-8 -*-
 3# author:Y4er
 4
 5import requests
 6import json
 7import hashlib
 8
 9def getToken(phone,password):
10	url = 'http://app.zhidiantianxia.cn/api/Login/pwd'
11	headers = {
12	'Host': 'app.zhidiantianxia.cn',
13	'Content-Type': 'application/x-www-form-urlencoded',
14	'User-Agent': 'okhttp/3.10.0'
15	}
16	params = {
17		'phone': phone,
18		'password': password,
19		'mobileSystem': '8.1.0',
20		'appVersion': '1.1.4',
21		'mobileVersion': 'MI 6X',
22		'deviceToken': '1507bfd3f7ec78ab60e'
23	}
24	token = requests.post(url,params=params,headers=headers).json()['data']
25	return token
26
27def qianDao(phone,token):
28	url = 'http://zzrvtc.zhidiantianxia.cn/applets/signin/sign'
29	headers = {
30		'axy-phone': phone,
31		'axy-token': token,
32		'Content-Type': 'application/json',
33		'user-agent': 'MI 6X(Android/8.1.0) (com.axy.zhidian/1.1.4) Weex/0.18.0 1080x2030',
34		'Host': 'zzrvtc.zhidiantianxia.cn'
35	}
36	payload = {"lat":"34.794349","lng":"113.887287","signInId":1562}
37	res = requests.post(url,headers=headers,data=json.dumps(payload)).json()['msg']
38	print("手机号:{0} 签到结果:{1}".format(phone,res))
39
40def getPhoneAndPass():
41	results = []
42	with open('password.txt','r',encoding='utf-8') as f:
43		for line in f.readlines():
44			line = line.strip('\n')
45			phone = line.split('|')[0]
46			password = line.split('|')[1]
47			m = hashlib.md5()
48			m.update(b"axy_" + bytes(password,encoding = "utf8"))
49			password = m.hexdigest()
50			results.append([phone,password])
51		f.close()
52	return results
53
54if __name__ == '__main__':
55
56	results = getPhoneAndPass()
57	for phone,password in results:
58		token = getToken(phone, password)
59		qianDao(phone,token)

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

 1#!/usr/bin/env python3
 2# -*- coding: utf-8 -*-
 3# author:Y4er
 4
 5import requests
 6import json
 7import hashlib
 8import smtplib
 9from email.mime.text import MIMEText
10from email.header import Header
11
12def mailTome():
13	# 第三方 SMTP 服务
14	mail_host="smtp.ym.163.com"  #设置服务器
15	mail_user="[email protected]"    #用户名
16	mail_pass="smtppassword"   #口令 
17	sender = '[email protected]'
18	receivers = ['[email protected]']  # 接收邮件,可设置为你的QQ邮箱或者其他邮箱
19	message = MIMEText('指点天下签到完毕,请自行查看结果', 'plain', 'utf-8')
20	message['From'] = Header("[email protected]", 'utf-8')
21	message['To'] =  Header("指点天下签到完毕,请自行查看结果", 'utf-8')
22	subject = '指点天下签到完毕,请自行查看结果'
23	message['Subject'] = Header(subject, 'utf-8')
24	try:
25	    smtpObj = smtplib.SMTP() 
26	    smtpObj.connect(mail_host, 25)    # 25 为 SMTP 端口号
27	    smtpObj.login(mail_user,mail_pass)
28	    smtpObj.sendmail(sender, receivers, message.as_string())
29	    print ("邮件发送成功")
30	except smtplib.SMTPException:
31	    print ("Error: 无法发送邮件")
32
33def getToken(phone,password):
34	url = 'http://app.zhidiantianxia.cn/api/Login/pwd'
35	headers = {
36	'Host': 'app.zhidiantianxia.cn',
37	'Content-Type': 'application/x-www-form-urlencoded',
38	'User-Agent': 'okhttp/3.10.0'
39	}
40	params = {
41		'phone': phone,
42		'password': password,
43		'mobileSystem': '8.1.0',
44		'appVersion': '1.1.4',
45		'mobileVersion': 'MI 6X',
46		'deviceToken': '1507bfd3f7ec78ab60e'
47	}
48	token = requests.post(url,params=params,headers=headers).json()['data']
49	return token
50
51def getsignInId(phone,token):
52	url = 'http://zzrvtc.zhidiantianxia.cn/applets/signin/my'
53	headers = {
54		'axy-phone': phone,
55		'axy-token': token,
56		'user-agent': 'MI 6X(Android/8.1.0) (com.axy.zhidian/1.1.4) Weex/0.18.0 1080x2030',
57		'Host': 'zzrvtc.zhidiantianxia.cn'
58	}
59	params = {
60		'page': '0',
61		'size': '10'
62	}
63	signInId = requests.get(url,headers=headers,params=params).json()['data']['content'][0]['id']
64	return signInId
65
66def qianDao(phone,token):
67	url = 'http://zzrvtc.zhidiantianxia.cn/applets/signin/sign'
68	headers = {
69		'axy-phone': phone,
70		'axy-token': token,
71		'Content-Type': 'application/json',
72		'user-agent': 'MI 6X(Android/8.1.0) (com.axy.zhidian/1.1.4) Weex/0.18.0 1080x2030',
73		'Host': 'zzrvtc.zhidiantianxia.cn'
74	}
75	payload = {"lat":"34.794349","lng":"113.887287","signInId":getsignInId(phone,token)}
76	res = requests.post(url,headers=headers,data=json.dumps(payload)).json()['msg']
77	print("手机号:{0} 签到结果:{1}".format(phone,res))
78
79def getPhoneAndPass():
80	results = []
81	with open('password.txt','r',encoding='utf-8') as f:
82		for line in f.readlines():
83			line = line.strip('\n')
84			phone = line.split('|')[0]
85			password = line.split('|')[1]
86			m = hashlib.md5()
87			m.update(b"axy_" + bytes(password,encoding = "utf8"))
88			password = m.hexdigest()
89			results.append([phone,password])
90		f.close()
91	return results
92
93if __name__ == '__main__':
94	results = getPhoneAndPass()
95	for phone,password in results:
96		token = getToken(phone, password)
97		qianDao(phone,token)
98	mailTome()