Exemplo n.º 1
0
def get_depts():
    '''Gets the departments from gamma.byu.edu and yields

        CODE, Friendly Name
    '''
    b = BYUBrowser(special[0], special[1], URL)
    page = b.get_soup(URL)
    newpage = b.get_soup(page.find('a')['href'])
    ## open('loeein.html', 'w').write(page.prettify().encode('utf8'))

    form = newpage.find('form', {'name': 'RegOptions'})
    target = form['action']
    dct = soup_form(form)
    script = newpage.find(text=re.compile('window\.brownie'))
    brownie = re.findall("window\.brownie = '([^']+)'", script)[0]
    dct['brownie'] = brownie
    dct['YearTerm'] = '20125'
    dct['e'] = '@YearTerm'
    dct['parms'] = '20125'
    dct['c'] = 'regOfferings'

    real = b.get_soup(URL, dct)
    options = real.find('select', {'name': 'Department'})('option')
    for option in options:
        if option['value'] == '*':
            continue
        long_name = option.string.strip()
        # the long_name is generally prefixed by the code. strip it.
        if long_name.startswith(option['value'] + ' - '):
            long_name = long_name[len(option['value'] + ' - '):].strip()
        yield option['value'], long_name
Exemplo n.º 2
0
def dotheprofiling(pid, user):
    b = BYUBrowser(*special)
    program = b.get_program(pid, True)
    if pid:
        program.save(user)
    else:
        for course in program:
            course.save(user, None, False)
Exemplo n.º 3
0
def test_through():
    b = BYUBrowser(*special)
    program = b.get_program(UCORE, True)
    print program.pretty()
Exemplo n.º 4
0
def test_login():
    b = BYUBrowser(*special)
    stuff = b.get_program(UCORE)
Exemplo n.º 5
0
def test_getclasses():
    b = BYUBrowser(*special)
    text = b.get_classeslist(31044, 78)
    open("classes.html", "w").write(text)