cunyenrollment.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:CUNYFirst-Enrollment-Bot 作者: Maxthecoder1 项目源码 文件源码
def __init__(self):
        '''change these variables to fit your needs'''
        '''Go to twilio.com and create a free account'''
        self.accountsid =  '??????????'                # accountsid for twilio account, required to receive texts
        self.authtoken =   '??????????'                # authtoken for twilio account, required to receive texts
        self.mycellphone = '??????????'                # your cell phone number
        self.twiliocell =  '??????????'                # twilio cellnumber that will be used to send texts to your actual phone
        self.username =    '??????????'                # CUNYFIRST USERNAME
        self.password =    '??????????'                # CUNYFIRST PASSWORD
        '''In order to receive an email you must go myaccount.google.com/security and scroll all the way to he bottom.
           Then go to where it says 'Allow less secure apps: ON' and check OFF. You should get an email about the change '''
        self.gmailuser =   '??????????'               # GMAIL USER
        self.gmailpass =   '??????????'               # GMAIL PASSWORD
        self.recipient =   '??????????'               # Recipient email address (most likely your email)
        self.interval = 60                            # refresh interval in seconds

        '''Add shopping cart link is very important to this script. Go to CUNYFIRST, Click Enroll. Then choose your Term.
           Once you are are on the Shopping Cart Page, Right + Click on 'add' and Click on 'Copy Link Location'.
           Then copy and paste in here with single quotes. It should look like the link below'''
        self.addshoppingcartlink = 'https://hrsa.cunyfirst.cuny.edu/psc/cnyhcprd/EMPLOYEE/HRMS/c/SA_LEARNER_SERVICES.SSR_SSENRL_CART.GBL?Page=SSR_SSENRL_CART&Action=A&ACAD_CAREER=UGRD&EMPLID=12345678&ENRL_REQUEST_ID=&INSTITUTION=BKL01&STRM=1172'

        print("Starting Firefox and heading to CUNYFIRST")
        self.driver = webdriver.PhantomJS()
        self.driver.get('https://home.cunyfirst.cuny.edu')
        login = WebDriverWait(self.driver, timeout=30).until(
            EC.presence_of_element_located((By.NAME, "login")))
        login.send_keys(self.username)
        passs = self.driver.find_element_by_name("password")
        passs.send_keys(self.password, Keys.ENTER)
        studentcenter = WebDriverWait(self.driver, timeout=30).until(
            EC.presence_of_element_located((By.LINK_TEXT, "Student Center")))
        studentcenter.click()
        self.driver.get(self.addshoppingcartlink)
        shoppingcartlen = len(self.driver.find_elements_by_xpath("//table[@id='SSR_REGFORM_VW$scroll$0']/tbody/tr")) - 2
        self.shoppingcart = {}
        for i in range(0, shoppingcartlen):
            classname = self.driver.find_element_by_id("win0divP_CLASS_NAME$" + str(i)).text
            print(classname)
            status = self.driver.find_element_by_xpath(
                "//div[@id='win0divDERIVED_REGFRM1_SSR_STATUS_LONG$" + str(i) + "']/div/img").get_attribute('alt')
            self.shoppingcart[classname] = status
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号