Sfoglia il codice sorgente

上傳檔案到 'KDAIS1'

allen 4 anni fa
parent
commit
7cdafa1596
1 ha cambiato i file con 31 aggiunte e 0 eliminazioni
  1. 31 0
      KDAIS1/pi_work.py

+ 31 - 0
KDAIS1/pi_work.py

@@ -0,0 +1,31 @@
+import datetime
+import requests
+import urllib
+import time
+
+path ="http://www.aisky.com.tw/field/status.php"
+nr = "GTW009002001"
+
+def work():
+    x = datetime.datetime.now()
+    print(x)
+    if time.strftime('%M') == '00' or time.strftime('%M') == '30':
+            print ("It's on Time")
+            Net_log_Send()
+
+
+def Net_log_Send():
+    data = {'nr': nr, 'status':'work'}
+    data = urllib.parse.urlencode(data)
+    data = data.encode('utf-8')
+    req = urllib.request.Request(path, data)
+    req.add_header('User-Agent', 'Magic Browser')
+    resp = urllib.request.urlopen(req)
+    respData = resp.read()
+    print("time check  ok")
+
+
+
+while True:
+    work()
+    time.sleep(60)