import datetime import requests import urllib import time path ="http://www.aisky.com.tw/field/status.php" nr = "GTW009002012" 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)