-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarks.py
58 lines (53 loc) · 2.09 KB
/
marks.py
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
import json
import warnings
from bs4 import BeautifulSoup
import index
warnings.filterwarnings('ignore', 'Unverified HTTPS request')
url = "https://vtop.vit.ac.in/vtop/examinations/doStudentMarkView"
data = {
'authorizedID': index.username,
'semesterSubId': index.semester
}
url = index.unified_session.post(url, data=data, headers=index.headers, verify=False)
soup = BeautifulSoup(url.content, 'html.parser')
table = soup.find_all('table', {"class": "customTable"})
final_mark = []
final_mark1 = {}
if len(table) > 0:
tr = table[0].find_all('tr', {"class": "tableContent"})
for i in range(1, len(tr)):
if len(tr[i].find_all('td', {"align": "center"})) == 0: # Is a new subject
course_info = tr[i].find_all('td')
marks = {
'class_no': course_info[1].text,
'code': course_info[2].text,
'title': course_info[3].text,
'type': course_info[4].text,
'credit': course_info[5].text,
'faculty': course_info[7].text,
'slot': course_info[8].text
}
i = i + 1
details = []
innerTable = tr[i].find('table')
innerRows = innerTable.find_all('tr')
for j in range(1, len(innerRows)):
innertd = innerRows[j].find_all('td')
each_detail = {
"Sl.No.": innertd[0].text,
"Mark Title": innertd[1].text,
"Max. Mark": innertd[2].text,
"Weightage %": innertd[3].text,
"Status": innertd[4].text,
"Scored Mark": innertd[5].text,
"Weightage Mark": innertd[6].text,
"Remark": innertd[7].text
}
details.append(each_detail)
marks['details'] = details
final_mark.append(marks)
final_mark1['Marks'] = final_mark
final_mark1 = json.dumps(final_mark1)
final_mark1 = json.loads(final_mark1)
with open('marks.json', 'w') as outfile:
json.dump(final_mark1, outfile, indent=4)