-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcid_info_mtech.py
More file actions
31 lines (27 loc) · 898 Bytes
/
cid_info_mtech.py
File metadata and controls
31 lines (27 loc) · 898 Bytes
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
#install command
#python -m pip install pyserial
# -*- coding: utf-8 -*-
import requests, json, time, serial, datetime
ser = serial.Serial('COM3', 19200, timeout=1)
while True:
s = ser.read(100)
cid = s.decode('utf-8')
tel = cid[1:-1]
dt = datetime.datetime.now()
if(len(tel) >= 4):
try:
f = open("cid_info.txt", "a")
dt = datetime.datetime.now()
print(dt.strftime("%Y-%m-%d %H:%M:%S") + " : "+tel)
f.write(dt.strftime("%Y-%m-%d %H:%M:%S") + " : "+tel+"\n")
url = 'https://192.168.0.10/cid_info_mtech.php?hp='+tel
r = requests.get(url, timeout=3)
a = r.text
info = json.loads(a)
print(tel+ ' --> '+str(info[0])+' '+str(info[1])+' '+str(info[2])+' '+str(info[3])+' '+str(info[4])+'\n')
f.write(tel+ ' --> '+str(info[0])+' '+str(info[1])+' '+str(info[2])+' '+str(info[3])+' '+str(info[4])+'\n\n')
f.close()
except:
pass
f.close()
time.sleep(1)