├── .gitignore ├── README.md ├── payload.json └── main.py /.gitignore: -------------------------------------------------------------------------------- 1 | .env -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ERP Auth 2 | 3 | Script to Authenticate my university's ERP. 4 | 5 | `Note: This repository is only intended to used for educational purpose.` 6 | -------------------------------------------------------------------------------- /payload.json: -------------------------------------------------------------------------------- 1 | { 2 | "__EVENTTARGET": "", 3 | "__EVENTARGUMENT": "", 4 | "__VIEWSTATE": "/wEPDwULLTIwOTAyNDg3NDMPZBYCZg9kFgQCAQ9kFgICFQ8WAh4EaHJlZgUyLi4vZGVzaWduX2ZyYW1ld29yay9OZXdEYXNoYm9hcmQvZGlzdC9jc3MvQmx1ZS5jc3NkAgMPZBYCAgEPZBYIAgMPDxYIHgVXaWR0aBsAAAAAAOCVQAEAAAAeBkhlaWdodBsAAAAAACCMQAEAAAAeCEltYWdlVXJsBVB+L1RlbGVyaWsuV2ViLlVJLldlYlJlc291cmNlLmF4ZD9pbWdpZD05YWI0NTRiNGI5OGI0NjJlYmIwNzJhYjAyMmJiMWViZSZ0eXBlPXJiaR4EXyFTQgKAA2RkAhAPDxYGHwMFFy4uL2ltYWdlcy9EdW1teUxvZ28ucG5nHghDc3NDbGFzcwUHTG9nb0JveB8EAgJkZAISDxYCHglpbm5lcmh0bWxlZAIUDxYCHwBkZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAQUjY3RsMDAkQ29udGVudFBsYWNlSG9sZGVyMSRDaGVja0JveDEz6CXJALVHCL4sm43HSRlnMKt1rEZilVk8zI1sJ2+L1A==", 5 | "__VIEWSTATEGENERATOR": "CE95E3B5", 6 | "__EVENTVALIDATION": "/wEdAAfFP3ocNfF/gG9ALMCSZRGLV81WNt1mpwLL2zW1ewrLS3Qq+s+KEqCNvUmR1rBY5ca4Z67AOU/kzhzLV6X3P9qDKX+RG8XwdcP0xBy3CPsNqwM00h6IH/niWSnxqsLv1wpcrmMV3O38Ci5K+kVOqYVBhxT1om2OviOsIWpISeMlA22C1vEGsggzluJyUg8oQWw=" 7 | } 8 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from bs4 import BeautifulSoup 3 | import json,os 4 | from dotenv import load_dotenv 5 | from rich.table import Table 6 | from rich.console import Console 7 | 8 | console = Console() 9 | 10 | 11 | load_dotenv(os.path.join(os.path.dirname(__file__), ".env")) 12 | 13 | def login(username, password): 14 | req = requests.Session() 15 | payload = json.load(open('payload.json')) 16 | 17 | url = 'http://erp.uit.edu:803/StudentPortal/Student/EDU_EBS_STU_Login.aspx' 18 | 19 | payload['ctl00$ContentPlaceHolder1$txtRegistrationNo_cs'] = username 20 | payload['ctl00$ContentPlaceHolder1$txtPassword_m6cs'] = password 21 | payload['ctl00$ContentPlaceHolder1$btnlgn']= 'Login' 22 | 23 | req.post(url, data=payload) 24 | res = req.get('http://erp.uit.edu:803/StudentPortal/Student/EDU_EBS_STU_Dashboard.aspx') 25 | # res = req.get('http://erp.uit.edu:803/StudentPortal/Student/EDU_EBS_STU_ACD_StudentCourseHistory.aspx') 26 | res = req.get('http://erp.uit.edu:803/StudentPortal/Student/EDU_EBS_STU_Attendance.aspx') 27 | return res.text 28 | 29 | soup = BeautifulSoup(login(os.environ.get("rollno"), os.environ.get("password")), 'html.parser') 30 | # print(soup.find('span', {'id': 'ctl00_user_name'}).text) 31 | 32 | # table_class = "rgMasterTable" 33 | 34 | # table = soup.find('table', attrs={'class': table_class}) 35 | # table_body = table.find('tbody') 36 | 37 | # rows = table_body.find_all('tr') 38 | # data = [] 39 | # for row in rows: 40 | # cols = row.find_all('td') 41 | # cols = [ele.text.strip() for ele in cols] 42 | # data.append([ele for ele in cols if ele]) 43 | 44 | # table = Table(show_header=True, header_style="bold magenta", show_lines=True) 45 | # table.add_column("Course Code", style="dim", width=12) 46 | # table.add_column("Course Title", style="dim", width=12) 47 | # table.add_column("Credit Hours", style="dim", width=12) 48 | # table.add_column("Grade", style="dim", width=12) 49 | # table.add_column("Grade Point", style="dim", width=12) 50 | # table.add_column("Semester", style="dim", width=12) 51 | # table.add_column("Year", style="dim", width=12) 52 | 53 | # for i in range(len(data)): 54 | # table.add_row(data[i][0], data[i][1], data[i][2], data[i][3], data[i][4], data[i][5], data[i][6]) 55 | 56 | 57 | # console.print(table) 58 | 59 | table = "rgMasterTable" 60 | 61 | table = soup.find('table', attrs={'class': table}) 62 | table_body = table.find('tbody') 63 | 64 | rows = table_body.find_all('tr') 65 | data = [] 66 | for row in rows: 67 | cols = row.find_all('td') 68 | cols = [ele.text.strip() for ele in cols] 69 | data.append([ele for ele in cols if ele]) 70 | 71 | table = Table(show_header=True, header_style="bold magenta", show_lines=True) 72 | table.add_column("Course Code", style="dim", width=12) 73 | table.add_column("Section Code", style="dim", width=12) 74 | table.add_column("Total Classes", style="dim", width=12) 75 | table.add_column("Taken Classes", style="dim", width=12) 76 | 77 | table.add_column("Attended Classes", style="dim", width=12) 78 | table.add_column("Percentage", style="dim", width=12) 79 | 80 | for i in range(len(data)): 81 | table.add_row(data[i][0], data[i][1], data[i][2], data[i][3], data[i][4], data[i][5]) 82 | 83 | console.print(table) 84 | 85 | 86 | 87 | --------------------------------------------------------------------------------