Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 40 additions & 30 deletions erpres.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json

def attempt(rollno, dob):
url = 'http://14.139.195.241/Result/login.php'
url = 'https://webapps.iitbbs.ac.in/Result/login.php'
browser = mechanize.Browser()
browser.set_handle_robots(False)
response = browser.open(url)
Expand All @@ -15,43 +15,53 @@ def attempt(rollno, dob):
if browser.title().strip() != 'IIT BHUBANEWSAR':
return False
else :
soup = BeautifulSoup(response.read(), 'html.parser')
newUrl = 'https://webapps.iitbbs.ac.in/Result/result.php'
newResponse = browser.open(newUrl)
soup = BeautifulSoup(newResponse.read(), 'html.parser')
name = soup.find('h1', attrs={'class': 'section-heading-page-center'}).text[6:].strip()
tables = soup.find_all('table')
# grade = [rollno, name]
re = {}
re["dob"] = dob
re["sgpa"] = []
# re["sgpa"] = []
re["cgpa"] = []
re["name"] = name
re["grades"] = {"1" : {}, "2" : {}, "3" : {}, "4" : {}, "5" : {}, "6" : {}, "7" : {}, "8" : {}}
for table in tables:
tr = table.find_all('tr')
gpa = tr[-1].find_all('td')
re["sgpa"].append(gpa[0].text.strip()[5:])
re["cgpa"].append(gpa[1].text.strip()[5:])
# print re
sem = tr[0].find("td").text.strip()[-1]
# re["grades"] = {"1" : {}, "2" : {}, "3" : {}, "4" : {}, "5" : {}, "6" : {}, "7" : {}, "8" : {}}
tr = tables[-1].find_all('tr')
gpa = tr[-1].find_all('td')
# re["sgpa"].append(gpa[0].text.strip()[5:])
re["cgpa"].append(gpa[1].text.strip()[5:])
print(re["name"], "-", re["cgpa"])
# for table in tables:
# tr = table.find_all('tr')
# gpa = tr[-1].find_all('td')
# # re["sgpa"].append(gpa[0].text.strip()[5:])
# re["cgpa"].append(gpa[1].text.strip()[5:])
# print(re["name"], "-", re["cgpa"])
# sem = tr[0].find("td").text.strip()[-1]
# print(sem)
# if sem == 8:
# print(re["name"], "-", re["cgpa"])
# print sem
tr = tr[2:-1]
for row in tr:
# print(row)
td = row.find_all('td')
# for gp in td:
# print gp.text.strip()
# print(td)
subcode = td[0].text.strip()
subname = td[1].text.strip()
ltp = td[2].text.strip()
credit = td[3].text.strip()
re["grades"][sem][td[0].text.strip()] = td[4].text.strip()
with open("course.json") as c:
crs = json.load(c)
if subcode not in crs:
crs[subcode] = {"subnane": subname, "ltp": ltp, "credit": credit}
# tr = tr[2:-1]
# for row in tr:
# # print(row)
# td = row.find_all('td')
# # for gp in td:
# # print gp.text.strip()
# # print(td)
# subcode = td[0].text.strip()
# subname = td[1].text.strip()
# ltp = td[2].text.strip()
# credit = td[3].text.strip()
# re["grades"][sem][td[0].text.strip()] = td[4].text.strip()
# with open("course.json") as c:
# crs = json.loads(c.reads())
# if subcode not in crs:
# crs[subcode] = {"subnane": subname, "ltp": ltp, "credit": credit}

with open("course.json", "w") as c:
json.dump(crs, c)
# with open("course.json", "w") as c:
# json.dump(crs, c)
# print re
# gp_tuple = []
# for gp in td:
Expand All @@ -60,7 +70,7 @@ def attempt(rollno, dob):
# grade.append(gp_tuple[1][5:])

with open("stres.json") as f:
prev = json.load(f)
prev = json.loads(f.read())

prev[rollno] = re
with open('stres.json', 'w') as f:
Expand Down
14 changes: 8 additions & 6 deletions script.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
from generator import generate
import json

year = int(raw_input('Enter first two digit of Roll No. : '))
year = int(input('Enter first two digit of Roll No. : '))
# assert (year >= 14 and year <= 17), 'Entered Year is not correct'

branch = str(raw_input('Enter branch abbreviation : ')).upper()
branch = str(input('Enter branch abbreviation : ')).upper()
branches = ['CE', 'CS', 'ME', 'MM', 'EE', 'EC']
assert branch in branches, 'Entered branch abbreviation not correct'

degree = int(raw_input('Enter 1 for single degree and 2 for dual degree : '))
degree = int(input('Enter 1 for single degree and 2 for dual degree : '))
assert degree in [1, 2], 'Entered degree not correct'

lastroll = int(raw_input('Enter last possible Roll No. : '))
lastroll = int(input('Enter last possible Roll No. : '))
# assert lastroll <= 46 and lastroll >= 9, 'lastroll should be less than 46'
firstroll = int(raw_input('Enter first Roll No. : '))
firstroll = int(input('Enter first Roll No. : '))

#rollarray = [1-9.22, 8-8.72, 10- 8.58, 17- 8.54, 24, 41-9.21]

depc = []
for i in range(firstroll, lastroll):
Expand All @@ -25,7 +27,7 @@
roll = str(year) + str(branch) + '0' + str(degree) + '0' + str(i)

with open("stres.json") as f:
prev = json.load(f)
prev = json.loads(f.read())
if roll in prev:
continue
scheme = 0
Expand Down