-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPL.py
75 lines (58 loc) · 1.93 KB
/
PL.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
import requests
import os
from bs4 import BeautifulSoup
# Clear Console On Windows/Linux
def cls():
os.system('cls' if os.name=='nt' else 'clear')
# Format PosLaju Tracking Number To Be Accurate
def formatPL(tr):
length = 2
status = False
los = []
for i in range(0, len(tr), length):
los.append(tr[i:length])
if len(tr) == 14 and los[0] in ['EE','EH','EP','ER','EN','EM','PL']:
status = True
else:
status = False
return status
def exit():
ex = str(input("\nDo You Want To Continue? (Y/N):"))
ex = ex.upper()
print("\n")
if ex == 'Y':
cls()
main()
else:
return
def main():
print("#########################")
print("# PosLaju Tracker v0.1 #")
print("# Coded By Noor Aiman #")
print("########################\n")
tr_num = str(input("Tracking Number: "))
tr_num = tr_num.upper()
if(formatPL(tr_num)):
url = "https://sendparcel.poslaju.com.my/open/trace"
payload = {"tno":tr_num}
header = {
'Connection':'keep-alive',
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36'
}
res = requests.get(url,payload, headers = header)
html_data = res.content
# Get Table Row and Columns
table_data = [[cell.text for cell in row("td")]
for row in BeautifulSoup(html_data, features="lxml")("tr")]
if len(table_data) > 0:
del table_data[0] # Remove First Item - Contain Nothing
for date,status,place in table_data:
print("\nStatus: ", status)
print("Place: ", place)
print("Date: ", date)
else:
print("\nStatus: Tracking Not Found")
else:
print("Wrong Format!")
exit()
main()