Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ Hench why studcli was born, now you can easily call a python-command, and all yo
## How to use
1. Make sure you have Python installed
2. Install splinter via pip
3. Download the script.
4. Edit config.ini with your info and prefered settings
5. Run main.py using the python-command (python2)
6. (optionally) add ```alias studweb="python /path/to/studcli/main.py"``` in your zshconfig, so that you can run ```studweb``` from terminal
3. Install phantomjs ```sudo apt-get install phantomjs```
4. Download the script.
5. Edit config.ini with your info and prefered settings
6. Run main.py using the python-command (python2)
7. (optionally) add ```alias studweb="python /path/to/studcli/main.py"``` in your zshconfig, so that you can run ```studweb``` from terminal

## Disclaimer
I made this for my own sake, and it may or may not work on your studweb.
26 changes: 12 additions & 14 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,34 @@
parser = ConfigParser.ConfigParser()
parser.read(os.path.join(os.path.dirname(__file__), 'config.ini'))

browser = Browser(parser.get('Config', 'Browser'))
browser.driver.maximize_window()
browser = Browser('phantomjs')
browser.cookies.delete()
browser.driver.set_window_size(1920,1080)

browser.visit('https://fsweb.no/studentweb/login.jsf?inst=' + parser.get('Config', 'Institution'))
browser.find_by_text('Norwegian ID number and PIN').first.click()
browser.visit('http://fsweb.no/studentweb/login.jsf?inst=FSWACT')
browser.find_by_xpath("//div[@id='login-box']/div[@id='login-flaps']/div[@class='login-flap login-name-pin']").click()

browser.find_by_id('login-box')
browser.fill('j_idt129:j_idt131:fodselsnummer', parser.get('Config', 'Fodselsnummer'))
browser.fill('j_idt129:j_idt131:pincode', parser.get('Config', 'Pin'))
browser.find_by_text('Log in').first.click()

browser.click_link_by_href('/studentweb/resultater.jsf')
browser.find_by_xpath("//button[@id='j_idt129:j_idt131:login']").click()
browser.find_by_xpath("//nav[@id='menuBarLeft']/ul[@class='mainmenu']/li/a[@title='Resultater']").click()

grades = []
tags = browser.find_by_tag('tr')

chars = []

for tag in tags:
if tag.has_class('resultatTop') or tag.has_class('none'):
inner_tags = tag.find_by_tag('td')
course_id = inner_tags[1].text.split("\n")[0]
course_name = inner_tags[1].text.split("\n")[1]
grade = inner_tags[5].text
if grade != 'Passed':
chars.append(grade)

print "%s\t%-30s\t%s" % (course_id, course_name, grade)
grades.append(grade)
print "%s\t%-30s\t%s" % (course_id, course_name, grade)

total = 0.0
for char in chars:
for char in grades:
if char == 'A':
total += 6
elif char == 'B':
Expand All @@ -52,7 +50,7 @@



finalChar = total/len(chars)
finalChar = total/len(grades)

print ('------------------------------------------')
print ('Ditt nåværende karaktersnitt er: ' + str(finalChar))
Expand Down