本人報考哈工大計算機專業,因爲成績公示未公佈明確的查詢時間,心慌之下寫了小的查詢程序。
注:1. 在彈窗提示的手段裏,可以自己填寫,簡單的如彈出記事本,複雜的如直接彈出web(需要提前安裝selenium庫)
2. header裏的cookies要改成自己的,我這裏隱藏爲****
import requests import selenium import re import os import time def chaxun(): headers={"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "Accept-Encoding":"gzip, deflate, sdch", "Accept-Language":"zh-CN,zh;q=0.8", "Cache-Control":"max-age=0", "Connection":"keep-alive", "Cookie":"***********************", "Host":"221.207.246.181:8006", "Upgrade-Insecure-Requests":"1", "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"} content=requests.get("http://221.207.246.181:8006/JWWebCXZX/examTypeList",headers=headers) content=content.content.decode("utf-8") flag=re.findall(r"2018.*初試",content) return len(flag) == 1 def tanchu(): while True: f=chaxun() if f: os.system("notepad") #如果配置過selenium庫,則可以直接使用下面代碼打開瀏覽器 #from selenium import webdriver #browser = webdriver.Firefox() #browser.get("http://221.207.246.181:8006/JWWebCXZX/examTypeList") print("出成績啦") break else: print("暫未出成績") time.sleep(3) tanchu()