Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import sys
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.common.keys import Keys
- from bs4 import BeautifulSoup
- import time
- # Function to install packages
- def install(package):
- subprocess.check_call([sys.executable, "-m", "pip", "install", package])
- # List of required packages
- required_packages = ['selenium', 'beautifulsoup4']
- # Install packages if not already installed
- for package in required_packages:
- try:
- __import__(package)
- except ImportError:
- print(f"Installing {package}...")
- install(package)
- # Embed the password directly in the code (use with caution)
- username = "echenault"
- password = "One98four!!!" # Directly embedded password
- # Set up Selenium WebDriver (e.g., using Chrome)
- driver = webdriver.Chrome()
- # Open the SAML login page
- driver.get('https://evansvilledayschool.instructure.com/login/saml')
- # Wait for the SAML login page to load (adjust time as necessary)
- time.sleep(5)
- # Find the username and password fields and fill them in
- username_field = driver.find_element(By.NAME, "username") # Change to the actual field name or ID
- password_field = driver.find_element(By.NAME, "password") # Change to the actual field name or ID
- username_field.send_keys(username)
- password_field.send_keys(password)
- # Submit the login form
- password_field.send_keys(Keys.RETURN)
- # Wait for the login to complete and for the grades page to load
- time.sleep(10) # Adjust the sleep time as needed
- # Navigate to the grades page
- driver.get('https://evansvilledayschool.instructure.com/courses/941/grades')
- # Extract the page source
- page_source = driver.page_source
- # Parse the page with BeautifulSoup
- soup = BeautifulSoup(page_source, 'html.parser')
- # Find the element with the grade percentage
- grade_element = soup.find('span', class_='grade')
- if grade_element:
- # Extract and print the grade percentage
- grade_percentage = grade_element.text.strip()
- print(f"Grade: {grade_percentage}")
- else:
- print("Grade not found.")
- # Close the browser
- driver.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement