pi_work.py 713 B

12345678910111213141516171819202122232425262728293031
  1. import datetime
  2. import requests
  3. import urllib
  4. import time
  5. path ="http://www.aisky.com.tw/field/status.php"
  6. nr = "GTW009002007"
  7. def work():
  8. x = datetime.datetime.now()
  9. print(x)
  10. if time.strftime('%M') == '00' or time.strftime('%M') == '30':
  11. print ("It's on Time")
  12. Net_log_Send()
  13. def Net_log_Send():
  14. data = {'nr': nr, 'status':'work'}
  15. data = urllib.parse.urlencode(data)
  16. data = data.encode('utf-8')
  17. req = urllib.request.Request(path, data)
  18. req.add_header('User-Agent', 'Magic Browser')
  19. resp = urllib.request.urlopen(req)
  20. respData = resp.read()
  21. print("time check ok")
  22. while True:
  23. work()
  24. time.sleep(60)