zoukankan      html  css  js  c++  java
  • 选课人看了会流泪,教务处看了会沉默的神秘代码

    选课人看了会流泪,教务处看了会沉默的神秘代码

    """
    This is a script to choose your FAVOURITED curriculums on the NEW EASystem of NJU.
    It only works for students able to login via the General Authentication System.
    
    It's necessary to install the library request, selenium, and the geckodriver of FireFox first
    """
    
    import time
    import urllib.request
    from selenium import webdriver
    
    driver = webdriver.Firefox()
    
    url = "http://xk.nju.edu.cn"
    StudentId = "REPLACE WITH YOUR OWN ID"
    PassWord = "REPLACE WITH YOUR OWN PASSWORD" 
    
    driver.get(url)
    
    # Login via the General Authentication System
    driver.find_elements_by_id('username')[0].send_keys(StudentId)
    driver.find_elements_by_id('password')[0].send_keys(PassWord)
    driver.find_element_by_css_selector("#casLoginForm > p:nth-child(4) > button:nth-child(1)").click()
    time.sleep(0.1)
    
    # Here try except to avoid the unnecessarity to choose a mode
    try:
        # Replace the 0 in the next line to choose different mode
        driver.find_elements_by_xpath('.//*[@name="electiveBatchSelect"]')[0].click()
        driver.find_element_by_xpath('.//*[@type="button" and @data-index="0"]').click()
    except: pass
    driver.find_element_by_id('courseBtn').click()
    
    while True:
        driver.refresh()
        time.sleep(0.2)
        driver.find_element_by_xpath('//a[text()="收藏"]').click()
        curriculums = driver.find_elements_by_xpath('.//*[text()="选择"]')
    
        # Try to choose each of the favourited curriculum regardless of the feasibility
        for each in curriculums:
            try:
                each.click()
                driver.find_element_by_xpath('.//*[@data-type="sure"]').click()
                time.sleep(0.3)
                driver.find_element_by_xpath('.//*[@data-type="sure"]').click()
            except: pass
    
  • 相关阅读:
    3. 操作系统优化
    Linux 目录
    2. 系统的目录结构
    1. 系统管理以及操作命令
    7. 流程控制之for循环
    6. 流程控制之while循环
    我的第一篇博客园随笔
    H5自带进度条&滑块
    DIV水平方向居中的几种方法
    vue入门--简单嵌套路由的一个路径小问题
  • 原文地址:https://www.cnblogs.com/Shimarin/p/14486931.html
Copyright © 2011-2022 走看看