Skip to content

Commit 6efacb4

Browse files
committed
semester table enumeration
not fully working currently, table looks horrible
1 parent a2144d8 commit 6efacb4

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

campusnet.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,32 @@
3939

4040
response = requests.get('https://dualis.dhbw.de/scripts/mgrqispi.dll?APPNAME=CampusNet&PRGNAME=COURSERESULTS&ARGUMENTS=-N591469968597102,-N000307', data="", headers=headers)
4141

42-
print(response.text)
43-
4442
semester = {}
4543

4644
for match in re.findall('<option value=".*</option>', response.text):
4745
semester[match.split('>')[1].split('<')[0]]=match[15:30] #key=name, value=id
4846

4947
## Get all Prüfungen in Semester
5048

49+
table=list() # table is cross semester, so initialized outside
50+
51+
for semestername in semester:
52+
print(semestername)
53+
headers = {
54+
'Host': 'dualis.dhbw.de',
55+
'Cookie': cnsc,
56+
}
57+
response = requests.get(f'https://dualis.dhbw.de/scripts/mgrqispi.dll?APPNAME=CampusNet&PRGNAME=COURSERESULTS&ARGUMENTS=-N591469968597102,-N000307,-N{semester[semestername]}', data="", headers=headers) #get page with Prüfungen Table
58+
temptable = re.findall('<table class="nb list">[\s\S]*</table>', response.text)[0] # extract table from html body
59+
temptable = re.findall('<tbody>[\s\S]*</tbody>', temptable)[0] # extract table body from table
60+
temprows = temptable.split('<tr')[1:-1] # extract all rows from table. [0] is just <tbody ...>
61+
62+
for row in temprows:
63+
tempcells = row.split('<td')[1:] # extract all columns from table
64+
currentrow = list()
65+
for cell in tempcells:
66+
cell = cell.split('>', 1)[1].split('</td')[0] # extract content from cell
67+
currentrow.append(cell) # combine cells to row
68+
table.append(currentrow) # combine rows to table
69+
5170
## Get Prüfungen Results

0 commit comments

Comments
 (0)