Created
June 4, 2017 17:33
-
-
Save casdr/ffe4e2e4a7eb6f9b0bb1f29c3351a33d to your computer and use it in GitHub Desktop.
Get itslearning grades and format them nicely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = "Cas de Reuver" | |
__copyright__ = "Copyright (C) 2017 BlaLabs" | |
__license__ = "GPLv2" | |
__version__ = "1.1.0" | |
# heeft deze 2 dingetjes nodig | |
# kan gwn pip install beautifulsoup4 prettytable doen | |
from bs4 import BeautifulSoup | |
from prettytable import PrettyTable | |
import sys | |
fijl = open(sys.argv[1], 'r').read() | |
tomatensoep = BeautifulSoup(fijl, 'html.parser') | |
groupies = {} | |
for tomaat in tomatensoep.find_all(class_='ccl-accordion-section'): | |
sjors = tomaat.find(class_='ccl-accordion-section-header-container').get_text().strip() | |
nummertjes = [] | |
for nummertje in tomaat.find_all(class_='ccl-rwgm-col-three'): | |
nummertjes.append({ | |
'autobandventieldopje': nummertje.find(class_='gb-headerlink').get_text(), | |
'bushalte': nummertje.find(class_='assessmentcontainer').get_text().replace('Grade: ', '').replace('Cijfer: ', '') # begin te nederlandsen | |
}) | |
groupies[sjors] = nummertjes | |
poppetje = tomatensoep.find(class_='ccl-pageheader-title').get_text() | |
print("Grade list for " + poppetje) | |
print() | |
for titeltje, nummertjes in groupies.items(): | |
print(titeltje) | |
t = PrettyTable(['Name', 'Grade']) | |
for aardappel in nummertjes: | |
t.add_row([aardappel['autobandventieldopje'], aardappel['bushalte']]) | |
print(t) | |
print() | |
print("Legend: 7.5-10 = Goed, 5.5-7.5 = Beetje goed, 4.5-5.5 = Onvoldoende") | |
print("Generated by blalabs.itslearning.gradeparser") | |
print("Created by Cas de Reuver <cdreuver@blalabs.com>") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment