forked from OreosLab/checkinpanel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathck_hlx.py
118 lines (105 loc) · 3.73 KB
/
ck_hlx.py
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
116
117
118
# -*- coding: utf-8 -*-
"""
cron: 30 7 * * *
new Env('葫芦侠');
"""
import requests
from notify_mtr import send
from utils import get_data
r = requests.Session()
class HLX:
def __init__(self, check_items):
self.check_items = check_items
@staticmethod
def login(user, passwd):
url = (
"http://floor.huluxia.com/account/login/ANDROID/4.0?platform=2&gkey=000000&app_version=4.0.0.6.2"
"&versioncode=20141433&market_id=floor_baidu&_key=&device_code=%5Bw%5D02%3A00%3A00%3A00%3A00%3A00 "
)
params = {"account": user, "login_type": "2", "password": passwd}
login_res = r.post(url=url, data=params)
login_res = login_res.json()
nick = login_res["user"]["nick"]
key = login_res["_key"]
s_key = login_res["session_key"]
return nick, key, s_key
@staticmethod
def check(key):
url1 = "http://floor.huluxia.com/user/status/ANDROID/2.1"
params = {
"platform": "2",
"gkey": "000000",
"app_version": "4.0.0.6.3",
"versioncode": "20141434",
"market_id": "floor_baidu",
"_key": key,
"device_code": "%5Bw%5D02%3A00%3A00%3A00%3A00%3A00",
}
check_req = r.get(url=url1, params=params)
check_req = check_req.json()
status = check_req["status"]
if status == 0:
raise Exception("令牌验证失败")
return status
@staticmethod
def category(key):
global experienceVal
titles = []
categoryIDs = []
category_url = "http://floor.huluxia.com/category/list/ANDROID/2.0"
params = {
"platform": "2",
"gkey": "000000",
"app_version": "4.0.0.6.3",
"versioncode": "20141434",
"market_id": "floor_huluxia",
"_key": key,
"device_code": "%5Bw%5D02%3A00%3A00%3A00%3A00%3A00",
"is_hidden": "1",
}
category_res = r.get(url=category_url, params=params)
category_res = category_res.json()
category_res = category_res["categories"]
for i in range(3, len(category_res)):
res = category_res[i]
titles.append(res["title"])
categoryIDs.append(res["categoryID"])
# print(res)
url = "http://floor.huluxia.com/user/signin/ANDROID/4.0"
all_experienceVal = 0
for i in range(0, len(categoryIDs)):
IDS = str(categoryIDs[i])
params = {
"platform": "2",
"gkey": "000000",
"app_version": "4.0.0.6.3",
"versioncode": "20141434",
"market_id": "floor_baidu",
"_key": key,
"device_code": "%5Bw%5D02%3A00%3A00%3A00%3A00%3A00",
"cat_id": IDS,
}
try:
experienceVal = r.get(url=url, params=params).json()["experienceVal"]
except Exception:
experienceVal = 0
finally:
all_experienceVal = all_experienceVal + experienceVal
return "签到成功 共获得{}点经验".format(all_experienceVal)
def main(self):
msg_all = ""
for check_item in self.check_items:
username = check_item.get("username")
password = check_item.get("password")
nick, key, s_key = self.login(username, password)
self.check(key)
msg = "用户名:" + nick + self.category(key)
msg_all += msg + "\n\n"
return msg_all
def start():
data = get_data()
_check_items = data.get("HLX", [])
res = HLX(check_items=_check_items).main()
send("葫芦侠", res)
if __name__ == "__main__":
start()