This repository has been archived by the owner on Jul 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lankabell_usage_notify.py
108 lines (80 loc) · 3.92 KB
/
lankabell_usage_notify.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
import os
import json
import time
import base64
import requests
import win32gui, win32con
from bs4 import BeautifulSoup
from win10toast import ToastNotifier
credentials = {
'username' : '',
'password' : ''
}
while True:
try:
if os.path.exists('creds.json'):
with open('creds.json', 'r') as f:
data = json.load(f)
username = data['username']
password = data['password']
dec_username = base64.b64decode(username.encode())
dec_password = base64.b64decode(password.encode())
url = 'https://www.lankabell.com/lte/home1.jsp'
data = {'logName': dec_username, 'redirectFUP': 'null','password': dec_password, 'logtype': 'login', 'submit': 'Sign In'}
session = requests.session()
response = session.post(url,data=data).content.decode('utf-8')
x = session.cookies.get_dict()
soup = BeautifulSoup(response, 'lxml')
error = soup.find('div', {'id':'result'})
if not error:
try:
frgrnd_wndw = win32gui.GetForegroundWindow();
wndw_title = win32gui.GetWindowText(frgrnd_wndw);
if wndw_title.endswith("lankabell_usage_notify.exe"):
win32gui.ShowWindow(frgrnd_wndw, win32con.SW_HIDE);
except Exception:
pass
toaster = ToastNotifier()
span = soup.find_all('span', {'class':'styleCommon'})
days = span[10].text
url2 = 'https://www.lankabell.com/lte/usage.jsp'
t = requests.post(url2, cookies=x).content.decode('utf-8')
soup = BeautifulSoup(t, 'lxml')
spans = soup.find_all('span', {'class' : 'styleCommon'})
monthly_anytime = spans[0].text
monthly_offpeak = spans[1].text
m_combine = monthly_anytime + "\n" + monthly_offpeak
remaining_anytime = spans[2].text
remaining_offpeak = spans[3].text
r_combine = remaining_anytime + "\n" + remaining_offpeak + "\n" + "Data Validity Period: " + days
toaster.show_toast("Monthly Usage",
m_combine,
icon_path="fav.ico",
duration=6,
)
toaster.show_toast("Remaining Data",
r_combine,
icon_path="fav.ico",
duration=6,
)
time.sleep(3600)
else:
username = str(input("Username: "))
password = str(input("Password: "))
enc_username = base64.b64encode(username.encode())
enc_passwprd = base64.b64encode(password.encode())
credentials['username'] = enc_username.decode()
credentials['password'] = enc_passwprd.decode()
with open('creds.json', 'w') as f:
json.dump(credentials, f)
else:
username = str(input("Username: "))
password = str(input("Password: "))
enc_username = base64.b64encode(username.encode())
enc_passwprd = base64.b64encode(password.encode())
credentials['username'] = enc_username.decode()
credentials['password'] = enc_passwprd.decode()
with open('creds.json', 'w') as f:
json.dump(credentials, f)
except Exception:
quit()