forked from xiaocao666tzh/Airport-Checkin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
46 lines (41 loc) · 1.75 KB
/
main.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
import requests
import json
import os
requests.packages.urllib3.disable_warnings()
SCKEY = os.environ.get('SCKEY')
TG_BOT_TOKEN = os.environ.get('TGBOT')
TG_USER_ID = os.environ.get('TGUSERID')
def checkin(email=os.environ.get('EMAIL'), password=os.environ.get('PASSWORD'),
base_url=os.environ.get('BASE_URL'), ):
email = email.split('@')
email = email[0] + '%40' + email[1]
session = requests.session()
session.get(base_url, verify=False)
login_url = base_url + '/auth/login'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) '
'AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/56.0.2924.87 Safari/537.36',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
}
post_data = 'email=' + email + '&passwd=' + password + '&code='
post_data = post_data.encode()
response = session.post(login_url, post_data, headers=headers, verify=False)
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) '
'AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/56.0.2924.87 Safari/537.36',
'Referer': base_url + '/user'
}
response = session.post(base_url + '/user/checkin', headers=headers,
verify=False)
response = json.loads(response.text)
print(response['msg'])
return response['msg']
result = checkin()
if SCKEY != '':
sendurl = 'https://sctapi.ftqq.com/' + SCKEY + '.send?title=机场签到&desp=' + result
r = requests.get(url=sendurl)
if TG_USER_ID != '':
sendurl = f'https://api.telegram.org/bot{TG_BOT_TOKEN}/sendMessage?chat_id={TG_USER_ID}&text={result}&disable_web_page_preview=True'
r = requests.get(url=sendurl)