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
    
  • 相关阅读:
    Oracle的序列、视图、索引和表空间
    MySQL存储过程
    MySQL触发器
    MySQL索引和视图
    完整性约束
    Mybatis的核心对象及运行流程
    Mybatis中配置连接池
    IDEA中创建Maven工程整合Mybatis
    Idea中创建JavaWeb工程
    实现整数集合的并、交、差运算
  • 原文地址:https://www.cnblogs.com/Shimarin/p/14486931.html
Copyright © 2011-2022 走看看