1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import requests
- import time
- import re
- from lxml import etree
- from SendMessage import send_message
- cookie2 = 'cookiesession1=678B2867VWXYZACFHJLNPRTVXZBDD68F; JSESSIONID=qxRvln9OcQvtB2tsyMZNFsaFPIezr2xrNOfd1XVwfL5foSuYGOEQ!-2081256861; BIGipServerpool-hub-wsxkxt=2919893514.22811.0000'
- cookie1 = 'cookiesession1=678B2867VWXYZACFHJLNPRTVXZBDD68F; JSESSIONID=X6Q3JYn4xVtAvSnRsMlxbiWuxUSXcQ-kDf2b4ytHmfHMpBX8EDyv!1902579802; BIGipServerpool-hub-wsxkxt=2987002378.22811.0000'
- cookie = 'cookiesession1=678B2867VWXYZACFHJLNPRTVXZBDD68F; JSESSIONID=xmo6YX8cwTge1snOno9v9iMoBZ2rOYfGMtwYu3ZFKOB8NdFYZ3Sq!1902579802; BIGipServerpool-hub-wsxkxt=2987002378.22811.0000'
- headers = {
- 'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.54',
- 'cookie':cookie2,
- 'host':'wsxk.hust.edu.cn'
- }
- root = 'http://wsxk.hust.edu.cn/zxqcourse/index_zxq.jsp'
- classlist = 'http://wsxk.hust.edu.cn/zxqstudentcourse/courseorclassroom.action?markZB=a'
- class1 = 'http://wsxk.hust.edu.cn/zxqstudentcourse/zxqclassroom.action?kcbh=w903964&ggkdl=&markZB='
- def solve_text_rcode(img):
- image = Image.open(img)
- text = pytesseract.image_to_string(image)
- time.sleep(5)
- print(text)
- return text
- def main():
- driver = webdriver.Edge()
- wait = WebDriverWait(driver, 10)
- driver.get(root)
- time.sleep(1)
- landing_btn = driver.find_element_by_class_name("landing_btn_bg")
- landing_btn.click()
- wait.until(EC.presence_of_element_located((By.ID,"un")))
- username = driver.find_element_by_id("un")
- username.send_keys("U202214377")
- password = driver.find_element_by_id("pd")
- password.send_keys("Zym00741")
- rcode_img = driver.find_element_by_id("codeImage").screenshot('temp.png')
- # img_url = 'https://pass.hust.edu.cn/cas/code'
- # with open('temp.gif','wb') as f:
- # print(driver.get_cookie(driver.current_url))
- # img = requests.get('https://pass.hust.edu.cn/cas/code',headers=headers1).content
- # f.write(img)
- rcode = driver.find_element_by_id("code")
- rcode.send_keys(solve_text_rcode("temp.png"))
- time.sleep(5)
- login_btn = driver.find_element_by_class_name("login_box_landing_btn")
- login_btn.click()
- input("WAITING...")
- driver.close()
- if __name__ == "__main__":
- # main()
- while True:
- time.sleep(3)
- response = requests.get(class1, headers=headers)
- if response.status_code == 200:
- print("success!")
- # print(response.text)
- html = etree.HTML(response.text)
- lst = html.xpath('//table/tr[@class="tablelist"]/td/text()')
- # print(lst)
- num = lst[6]
- num = re.sub("\r", "", num)
- num = re.sub(" ", "", num)
- num = re.sub("\n", "", num)
- # print(num)
- if num == "40/40":
- print('已满')
- # send_message("private",2945340446,"已满!!!")
- else:
- print(num)
- print("有空缺!!!")
- send_message("private",2945340446,num + "有空缺!!!")
- break
|