diff --git a/PageLogin.py b/PageLogin.py index 14a07ff..38b3620 100644 --- a/PageLogin.py +++ b/PageLogin.py @@ -4,13 +4,15 @@ from getpass import getpass import no_graph_features as ngf from course_details import tabulate_course_details +from selenium.webdriver.firefox.service import Service +from webdriver_manager.firefox import GeckoDriverManager from selenium.webdriver.firefox.options import Options +from selenium.webdriver.common.by import By options = Options() options.headless = True -# Specify Path to geckodriver for Firefox -driver = webdriver.Firefox(options=options, executable_path=r"./geckodriver-v0.26.0-linux64/geckodriver") +driver = webdriver.Firefox(options=options, service=Service(executable_path=GeckoDriverManager().install())) # Navigating to the webpage driver.get("https://www.iitm.ac.in/viewgrades/") @@ -19,22 +21,22 @@ # Loop prompting correct login details tried = False -while driver.current_url=="https://www.iitm.ac.in/viewgrades/index.html" or driver.current_url=="https://www.iitm.ac.in/viewgrades/": +while driver.current_url=="https://www.iitm.ac.in/viewgrades/index.html" or driver.current_url=="https://www.iitm.ac.in/viewgrades/": if tried == True: # Check if it is not the first iteration print("Incorrect Roll Number and/or Password") # Locate form fields - rollno = driver.find_element_by_name("rollno") - pwd = driver.find_element_by_name("pwd") + rollno = driver.find_element(By.NAME, "rollno") + pwd = driver.find_element(By.NAME, "pwd") roll = input("Enter your roll number:") password = getpass("Enter your password:") rollno.send_keys(roll) pwd.send_keys(password) - driver.find_element_by_name("submit").click() + driver.find_element(By.NAME, "submit").click() tried = True @@ -44,10 +46,10 @@ # Intro greeting -name = driver.find_element_by_xpath("/html/body/center/table/tbody/tr/th[3]") +name = driver.find_element(By.XPATH, "/html/body/center/table/tbody/tr/th[3]") print("Hi,", name.text) -cg = driver.find_element_by_xpath("/html/body/center/center/table[1]/tbody/tr[last()]/td[last()]") +cg = driver.find_element(By.XPATH, "/html/body/center/center/table[1]/tbody/tr[last()]/td[last()]") print("Your", cg.text) courses, sem = tabulate_course_details(driver) @@ -59,7 +61,7 @@ choice = input('''\nHow do you want you visualize your grades: a) GPA for courses taken in a specific department - Other features will come soon. + Other features will come soon. Enter x to exit ''') @@ -67,5 +69,3 @@ dept, gpa = ngf.Dept_GPA(courses) print("Your GPA of the courses done in", dept, "department is", gpa, "\n") dummy = input('''Press Enter to continue''') - - diff --git a/course_details.py b/course_details.py index abe91bb..94f1c52 100644 --- a/course_details.py +++ b/course_details.py @@ -1,16 +1,19 @@ +from selenium.webdriver.common.by import By + def tabulate_course_details(driver): ''' driver: Webdriver element returns: Course and Semester details in a tabular format ''' - courses = driver.find_element_by_xpath("/html/body/center/center/table[1]/tbody").text + courses = driver.find_element(By.XPATH, "/html/body/center/center/table[1]/tbody").text course_list = courses.split('\n') #print(course_list) course_list = [i.split() for i in course_list] + count = 0 course_code = [] course_name = [] course_category = [] @@ -32,7 +35,7 @@ def tabulate_course_details(driver): credits.append((int(i[1][-2:]), count)) else: credits.append((int(i[1][-1]), count)) - + else: count = 0 sem.append(' '.join(i[:])) @@ -40,4 +43,4 @@ def tabulate_course_details(driver): course_summary = (course_code, course_name, course_category, course_credits, course_grade) sem_summary = (sem, credits) - return course_summary, sem_summary \ No newline at end of file + return course_summary, sem_summary diff --git a/geckodriver-v0.31.0-linux64/geckodriver b/geckodriver-v0.31.0-linux64/geckodriver new file mode 100755 index 0000000..1bd1945 Binary files /dev/null and b/geckodriver-v0.31.0-linux64/geckodriver differ diff --git a/no_graph_features.py b/no_graph_features.py index 65afcbc..5b38c52 100644 --- a/no_graph_features.py +++ b/no_graph_features.py @@ -8,7 +8,7 @@ def Dept_GPA(courses): ''' while True: dept = input("Enter the department code: ") - total_credits = 0 + total_credits = 0 total_points = 0 for i in range(len(courses[0])): if courses[0][i][:2] == dept: @@ -19,4 +19,4 @@ def Dept_GPA(courses): pass gpa = round(total_points/total_credits, 2) - return dept, gpa \ No newline at end of file + return dept, gpa