import requests, os ABS_PATH = os.path.dirname(os.path.realpath(__file__)) + '/' res = requests.get('http://exam.aiacademy.tw/exam/index.php?nc') res = res.text.encode('utf-8') if res.find("setInterval")>=0 or res.find("frm_choose_exam")>=0: with open(ABS_PATH+'index.without_postdata.cache','w') as f: f.write(res)