-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
129 lines (117 loc) · 3.74 KB
/
index.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
119
120
121
122
123
124
125
126
127
128
129
import datetime
import os
import re
import sys
import requests
from bs4 import BeautifulSoup
# server酱key
key = ''
# 账号
email = ''
# 密码
passwd = ''
# session
session = requests.session()
# 登陆
def login(host):
url = '{}/auth/login'.format(host)
params = {
'email': email,
'passwd': passwd,
'code': ''
}
headers = {
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Origin': url,
'Referer': '{}/auth/login'.format(url),
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
'X-Requested-With': 'XMLHttpRequest',
}
res = session.post(url=url, headers=headers, data=params, timeout=30)
msg = res.json()['msg']
print(msg)
ret = ''
if msg == '登录成功':
# 登陆成功之后,去更新hosts.txt
del headers['Content-Type']
html = session.get('{}/user'.format(host), headers=headers, timeout=30).text
soup = BeautifulSoup(html, 'lxml')
hosts = set()
for i in soup.find_all('h5'):
a = i.find('a', text=re.compile('http.*'))
if a:
hosts.add(a.text)
with open('hosts.txt', 'w', encoding='utf-8') as f:
for i in hosts:
f.write('{}\n'.format(i))
# 获取登陆信息
statistics = soup.find_all(class_='card card-statistic-2')
for i in statistics:
for j in i.text.split('\n'):
if len(j) > 1:
a = j.replace('\n', '').replace('\r', '').replace('升级套餐', '').strip()
ret += a + ' '
ret += '\n\n'
return ret
else:
raise Exception(msg)
# 速鹰666签到领流量
def clockIn(host):
url = '{}/user/checkin'.format(host)
headers = {
'Connection': 'keep-alive',
'Content-Length': '0',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'X-Requested-With': 'XMLHttpRequest',
'Origin': url,
'Referer': '{}/user'.format(host),
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9',
}
res = session.post(url=url, headers=headers, timeout=30)
json = res.json()
print(json)
return json
def sendMessage(msg):
# print(msg)
if key:
res = requests.post(
url='https://sc.ftqq.com/' + key + '.send',
data={
'title': '速鹰666自动签到结果通知',
'desp': msg
},
timeout=30
)
# print(res.text)
def main_handler(event, context):
hosts = [i.strip() for i in open('hosts.txt', 'r', encoding='utf-8').readlines()]
for host in hosts:
try:
print('try', host)
lmsg = login(host)
json = clockIn(host)
msg = json['msg']
ret = json['ret']
# print(lmsg + '今日签到 ' + msg)
if ret == 1:
sendMessage(lmsg + '今日签到 ' + msg)
break
else:
break
except Exception as e:
print(e)
if __name__ == '__main__':
os.chdir(os.path.dirname(os.path.abspath(__file__)))
if len(sys.argv) != 4:
print('usage:python3 {} "email" "passwd" "key"'.format(sys.argv[0]))
exit()
print(datetime.datetime.now())
email, passwd, key = sys.argv[1:]
if (not len(email)) or (not len(passwd)):
print('email or passwd is null')
exit()
main_handler({}, {})