-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
62 lines (46 loc) · 1.58 KB
/
main.py
File metadata and controls
62 lines (46 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import ConfigParser, os
from splinter import Browser
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.visit('https://fsweb.no/studentweb/login.jsf?inst=' + parser.get('Config', 'Institution'))
browser.find_by_text('Norwegian ID number and PIN').first.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')
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)
total = 0.0
for char in chars:
if char == 'A':
total += 6
elif char == 'B':
total += 5
elif char == 'C':
total += 4
elif char == 'D':
total += 3
elif char == 'E':
total += 2
elif char == 'F':
total += 1
finalChar = total/len(chars)
print ('------------------------------------------')
print ('Ditt nåværende karaktersnitt er: ' + str(finalChar))
print ('------------------------------------------')
browser.cookies.delete()
browser.quit()