Skip to content

Commit

Permalink
Merge pull request #19 from ThilakReddyy/develop
Browse files Browse the repository at this point in the history
Added:Mba
  • Loading branch information
ThilakReddyy committed Jun 16, 2023
2 parents 12a4e96 + 3840273 commit 1160bbe
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 3 deletions.
32 changes: 30 additions & 2 deletions jntuhresults/Executables/examcodes_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ def categorize_exam_code(result_text, exam_code):
return None


def categorize_masters_exam_code(result_text,exam_code):
# Categorize the masters exam code based on the result text
if " I Semester" in result_text:
return "1-1"
elif " II Semester" in result_text:
return "1-2"
elif " III Semester" in result_text:
return "2-1"
elif " IV Semester" in result_text:
return "2-2"
else:
return None

def get_exam_codes():
url = "http://results.jntuh.ac.in/jsp/home.jsp"
response = requests.get(url)
Expand All @@ -49,10 +62,22 @@ def get_exam_codes():
},
"bpharmacy": {
"R17": {}
},
"Mpharmacy":{
"R19":{},
"R22":{}
},
"MTech":{
"R19":{},
"R22":{}
},
"MBA":{
"R19":{},
"R22":{}
}
}
degree=list(exam_codes.keys())
for table in range(0,2):
for table in range(0,5):
results = soup.find_all("table")[table].find_all("tr")
regulations=exam_codes[degree[table]].keys()

Expand All @@ -65,7 +90,10 @@ def get_exam_codes():
for regulation in regulations:
if regulation in result_text:
exam_code = extract_exam_code(result_link)
category = categorize_exam_code(result_text, exam_code)
if(table<2):
category = categorize_exam_code(result_text, exam_code)
else:
category = categorize_masters_exam_code(result_text,exam_code)

if category is not None:
exam_codes[degree[table]][regulation].setdefault(category, [])
Expand Down
50 changes: 49 additions & 1 deletion jntuhresults/Executables/jntuhresultscraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,45 @@ def __init__(self, roll_number):
'4-1': ['663', '705', '754', '794', '832', '836'],
'4-2': ['678', '700', '789', '809']
}
},
'mpharmacy': {
'R19':
{
'1-1': ['319', '332', '347', '356', '371', '382', '388'],
'1-2': ['328', '336', '344', '353', '368', '379', '387'],
'2-1': ['337', '350', '365', '376', '386'],
'2-2': ['340', '374', '385']
},
'R22':
{
'1-1': ['389']
}
},
'mTech': {
'R19':
{
'1-1': ['161', '177', '185', '198', '209', '215'],
'1-2': ['157', '165', '174', '182', '195', '206', '214'],
'2-1': ['166', '180', '194', '204', '213'],
'2-2': ['169', '203', '212']
},
'R22':
{
'1-1': ['216']
}
},
'mba': {
'R19':
{
'1-1': ['297', '316', '323', '350', '362', '368'],
'1-2': ['122', '293', '302', '313', '320', '347', '359', '367'],
'2-1': ['303', '310', '344', '356', '366'],
'2-2': ['120', '307', '341', '353', '365']
},
'R22':
{
'1-1': ['369']
}
}
}

Expand All @@ -59,7 +98,8 @@ def __init__(self, roll_number):
# Payloads for different types of result requests
self.payloads={
"btech":["&degree=btech&etype=r17&result=null&grad=null&type=intgrade&htno=","&degree=btech&etype=r17&result=gradercrv&grad=null&type=rcrvintgrade&htno="],
"bpharmacy":["&degree=bpharmacy&etype=r17&grad=null&result=null&type=regular&htno=","&degree=bpharmacy&etype=r17&grad=null&result=gradercrv&type=rcrvintgrade&htno="]
"bpharmacy":["&degree=bpharmacy&etype=r17&grad=null&result=null&type=regular&htno=","&degree=bpharmacy&etype=r17&grad=null&result=gradercrv&type=rcrvintgrade&htno="],
"mba":["&degree=mba&grad=pg&etype=null&result=grade17&type=intgrade&htno=","&degree=mba&grad=pg&etype=r16&result=gradercrv&type=rcrvintgrade&htno="]
}

async def fetch_result(self, session, exam_code, payload):
Expand Down Expand Up @@ -160,6 +200,14 @@ async def scrape_all_results(self, exam_code="all"):
payloads = self.payloads["bpharmacy"]
# Set the exam codes for bpharmacy
exam_codes = self.exam_codes["bpharmacy"]["R17"]

elif self.roll_number[5]=="E":
# Set payloads to MBA
payloads = self.payloads["mba"]

# Determine the exam codes based on the roll number prefix
exam_codes = self.exam_codes["mba"]["R22" if self.roll_number[:2] == "22" else "R19"]

else:
return self.results

Expand Down

0 comments on commit 1160bbe

Please sign in to comment.