mirror of
				https://github.com/assenzostefano/class-website.git
				synced 2025-06-06 00:39:12 +02:00 
			
		
		
		
	It finally takes homework automatically, I just have to enter the dates and upload them to the database - I started a very basic but still very broken login system.
This commit is contained in:
		
							
								
								
									
										34
									
								
								app.py
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								app.py
									
									
									
									
									
								
							| @@ -1,5 +1,6 @@ | |||||||
| from flask import Flask, render_template, request, session, jsonify | from flask import Flask, render_template, request, session, jsonify, redirect | ||||||
| import requests | import requests | ||||||
|  | import pymongo | ||||||
| import logging | import logging | ||||||
| import bcrypt | import bcrypt | ||||||
| import sys | import sys | ||||||
| @@ -46,6 +47,37 @@ def api(): | |||||||
|         data = "hello world" |         data = "hello world" | ||||||
|         return jsonify({'data': data}) |         return jsonify({'data': data}) | ||||||
|  |  | ||||||
|  | @app.route('/login', methods = ['GET', 'POST']) | ||||||
|  | def login(): | ||||||
|  |     #Create login with Mongodb | ||||||
|  |     logging.info("A user went up: Login") | ||||||
|  |     message = 'Please login to your account' | ||||||
|  |     if "email" in session: | ||||||
|  |         return redirect(url_for("logged_in")) | ||||||
|  |  | ||||||
|  |     if request.method == "POST": | ||||||
|  |         email = request.form.get("email") | ||||||
|  |         password = request.form.get("password") | ||||||
|  |  | ||||||
|  |         | ||||||
|  |         email_found = records.find_one({"email": email}) | ||||||
|  |         if email_found: | ||||||
|  |             email_val = email_found['email'] | ||||||
|  |             passwordcheck = email_found['password'] | ||||||
|  |              | ||||||
|  |             if bcrypt.checkpw(password.encode('utf-8'), passwordcheck): | ||||||
|  |                 session["email"] = email_val | ||||||
|  |                 return redirect(url_for('logged_in')) | ||||||
|  |             else: | ||||||
|  |                 if "email" in session: | ||||||
|  |                     return redirect(url_for("logged_in")) | ||||||
|  |                 message = 'Wrong password' | ||||||
|  |                 return render_template('login.html', message=message) | ||||||
|  |         else: | ||||||
|  |             message = 'Email not found' | ||||||
|  |             return render_template('login.html', message=message) | ||||||
|  |     return render_template('login.html', message=message) | ||||||
|  |          | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|    logging.info("Web server started!")  |    logging.info("Web server started!")  | ||||||
|    app.run() |    app.run() | ||||||
							
								
								
									
										33
									
								
								src/dynamic_pages/login/login.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/dynamic_pages/login/login.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | |||||||
|  | from flask import Flask, render_template, request, session, jsonify, redirect, flash, url_for | ||||||
|  | from dotenv import load_dotenv | ||||||
|  | from flask_pymongo import PyMongo | ||||||
|  | import requests | ||||||
|  | import urllib | ||||||
|  | import pymongo | ||||||
|  | import logging | ||||||
|  | import bcrypt | ||||||
|  | import sys | ||||||
|  | import os | ||||||
|  |  | ||||||
|  | load_dotenv() #Load .env file | ||||||
|  | PASSWORD_MONGODB = os.getenv('PASSWORD_MONGODB') #Password for MongoDB | ||||||
|  | URL_MONGODB = os.getenv('URL_MONGODB') #URL for MongoDB | ||||||
|  | mongo_url = "mongodb+srv://elci:" + urllib.parse.quote_plus(PASSWORD_MONGODB) + URL_MONGODB #URL for MongoDB (with password) | ||||||
|  | client = pymongo.MongoClient(mongo_url) #Connect to MongoDB | ||||||
|  | database = client["website-class"] #Database name | ||||||
|  | collection = database["school-time-table"] #Collection school time table current | ||||||
|  | collection_archive = database["archive-school-time-table"] #Collection school time table archive | ||||||
|  |  | ||||||
|  | app = Flask(__name__) | ||||||
|  | app.config['SECRET_KEY'] = os.getenv('PASSWORD_MONGODB') | ||||||
|  | app.config['MONGO_dbname'] = 'website-class' | ||||||
|  | app.config['MONGO_URI'] = mongo_url | ||||||
|  | mongo = PyMongo(app) | ||||||
|  |  | ||||||
|  | @app.route('/login', methods = ['GET', 'POST']) | ||||||
|  | def login(): | ||||||
|  |     if request.method == 'POST': | ||||||
|  |          | ||||||
|  |          | ||||||
|  | if __name__ == '__main__': | ||||||
|  |    app.run() | ||||||
| @@ -1,9 +1,10 @@ | |||||||
| # Libraries for open and use Firefox | # Libraries for open and use Firefox | ||||||
| from selenium import webdriver |  | ||||||
| from selenium.webdriver.common.by import By |  | ||||||
| from selenium.webdriver.firefox.options import Options |  | ||||||
| from selenium.webdriver.support import expected_conditions as EC | from selenium.webdriver.support import expected_conditions as EC | ||||||
| from selenium.webdriver.support.ui import WebDriverWait | from selenium.webdriver.support.ui import WebDriverWait | ||||||
|  | from selenium.common.exceptions import TimeoutException | ||||||
|  | from selenium.webdriver.firefox.options import Options | ||||||
|  | from selenium.webdriver.common.by import By | ||||||
|  | from selenium import webdriver | ||||||
|  |  | ||||||
| # Libraries for MongoDB and .env file | # Libraries for MongoDB and .env file | ||||||
| from pymongo import MongoClient | from pymongo import MongoClient | ||||||
| @@ -22,24 +23,114 @@ URL_MONGODB = os.getenv('URL_MONGODB') #URL for MongoDB | |||||||
| mongo_url = "mongodb+srv://elci:" + urllib.parse.quote_plus(PASSWORD_MONGODB) + URL_MONGODB #URL for MongoDB (with password) | mongo_url = "mongodb+srv://elci:" + urllib.parse.quote_plus(PASSWORD_MONGODB) + URL_MONGODB #URL for MongoDB (with password) | ||||||
| client = pymongo.MongoClient(mongo_url) #Connect to MongoDB | client = pymongo.MongoClient(mongo_url) #Connect to MongoDB | ||||||
| database = client["website-class"] #Database name | database = client["website-class"] #Database name | ||||||
| collection = database["school-time-table"] #Collection school time table current | collection = database["homework"] #Collection school time table current | ||||||
|  |  | ||||||
| # Settings for Firefox |  | ||||||
| options = Options() | options = Options() | ||||||
| options.add_argument("--headless") # Headless mode (so you don't see the browser) | options.add_argument("--headless") # Headless mode (so you don't see the browser) | ||||||
| options.add_argument('--disable-gpu') # Disable GPU | options.add_argument('--disable-gpu') # Disable GPU | ||||||
|  |  | ||||||
| driver = webdriver.Firefox(options=options) # Open Firefox and set options | driver = webdriver.Firefox(options=options) # Open Firefox and set options | ||||||
| driver.get("https://nuvola.madisoft.it/login") # Open Nuvola website |  | ||||||
|  |  | ||||||
| def recheck(): | def giorno_cinque(): | ||||||
|     time.sleep(10) |     #Giorno cinque | ||||||
|     check_homework() |  | ||||||
|  |  | ||||||
| def connect_to_nuvola(): |  | ||||||
|     try: |     try: | ||||||
|         username = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, "username"))) # Wait for the username input |         print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) | ||||||
|         password = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, "password"))) # Wait for the password input |         try: | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/div/ul/li/p"))).text) | ||||||
|  |         except TimeoutException: | ||||||
|  |             WebDriverWait(driver, 250).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]"))).click() | ||||||
|  |     except TimeoutException: | ||||||
|  |         try: | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/div/ul/li/p"))).text) | ||||||
|  |         except TimeoutException: | ||||||
|  |             WebDriverWait(driver, 250).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]"))).click() | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def giorno_quattro(): | ||||||
|  |     #Giorno quattro | ||||||
|  |     try: | ||||||
|  |         print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) | ||||||
|  |         try: | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/div/ul/li/p"))).text) | ||||||
|  |         except TimeoutException: | ||||||
|  |             WebDriverWait(driver, 250).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]"))).click() | ||||||
|  |             giorno_cinque() | ||||||
|  |     except TimeoutException: | ||||||
|  |         try: | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/div/ul/li/p"))).text) | ||||||
|  |         except TimeoutException: | ||||||
|  |             WebDriverWait(driver, 250).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]"))).click() | ||||||
|  |             giorno_cinque() | ||||||
|  |  | ||||||
|  | def giorno_tre(): | ||||||
|  |     #Giorno tre | ||||||
|  |     try: | ||||||
|  |         print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) | ||||||
|  |         try: | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/div/ul/li/p"))).text) | ||||||
|  |         except TimeoutException: | ||||||
|  |             WebDriverWait(driver, 250).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]"))).click() | ||||||
|  |             giorno_quattro() | ||||||
|  |     except TimeoutException: | ||||||
|  |         try: | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/div/ul/li/p"))).text) | ||||||
|  |         except TimeoutException: | ||||||
|  |             WebDriverWait(driver, 250).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]"))).click() | ||||||
|  |             giorno_quattro() | ||||||
|  |  | ||||||
|  | def giorno_due(): | ||||||
|  |     #Giorno due | ||||||
|  |     try: | ||||||
|  |         print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) | ||||||
|  |         try: | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/div/ul/li/p"))).text) | ||||||
|  |         except TimeoutException: | ||||||
|  |             WebDriverWait(driver, 250).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]"))).click() | ||||||
|  |             giorno_tre() | ||||||
|  |  | ||||||
|  |     except TimeoutException: | ||||||
|  |         try: | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/div/ul/li/p"))).text) | ||||||
|  |         except TimeoutException: | ||||||
|  |             WebDriverWait(driver, 250).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]"))).click() | ||||||
|  |             giorno_tre() | ||||||
|  |  | ||||||
|  | def giorno_uno(): | ||||||
|  |     #Giorno uno | ||||||
|  |     driver.get("https://nuvola.madisoft.it/login")  # Open Nuvola website | ||||||
|  |     username = WebDriverWait(driver, 100).until(EC.element_to_be_clickable((By.ID, "username")))  # Wait for the username input | ||||||
|  |     password = WebDriverWait(driver, 100).until(EC.element_to_be_clickable((By.ID, "password")))  # Wait for the password input | ||||||
|  |  | ||||||
|     username.click() |     username.click() | ||||||
|     username.clear() |     username.clear() | ||||||
| @@ -50,70 +141,37 @@ def connect_to_nuvola(): | |||||||
|     WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div[1]/div[2]/div/div[2]/form/button"))).click() # Click on login button |     WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div[1]/div[2]/div/div[2]/form/button"))).click() # Click on login button | ||||||
|  |  | ||||||
|     # Section Homework |     # Section Homework | ||||||
|         WebDriverWait(driver, 100).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/div[1]/nav/div/div/a[6]"))).click() # Click on homework button |     WebDriverWait(driver, 250).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/div[1]/nav/div/div/a[6]"))).click() # Click on homework button | ||||||
|     except: |     try: | ||||||
|         print("Error in login") |         print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) | ||||||
|  |         try: | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/div/ul/li/p"))).text) | ||||||
|  |         except TimeoutException: | ||||||
|  |             WebDriverWait(driver, 250).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]"))).click() | ||||||
|  |             giorno_due() | ||||||
|  |     except TimeoutException: | ||||||
|  |         try: | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/div/ul/li/p"))).text) | ||||||
|  |             print(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/div/ul/li/p"))).text) | ||||||
|  |         except TimeoutException: | ||||||
|  |             WebDriverWait(driver, 250).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]"))).click() | ||||||
|  |             giorno_due() | ||||||
|  |  | ||||||
| def check_homework(): | giorno_uno() | ||||||
|     next_homework = 0 |  | ||||||
|     if next_homework == 10: |  | ||||||
|         print("ao basta") |  | ||||||
|     else: |  | ||||||
|         date = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[1]"))) # Print the date |  | ||||||
|         print(date.text()) |  | ||||||
|         try: |  | ||||||
|             homework_1 = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/div/ul/li/p"))) |  | ||||||
|             print(homework_1.text()) |  | ||||||
|             try: |  | ||||||
|                 homework_2 = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/div/ul/li/p"))) |  | ||||||
|                 print(homework_2.text()) |  | ||||||
|                 try: |  | ||||||
|                     homework_3 = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/div/ul/li/p"))) |  | ||||||
|                     print(homework_3.text()) |  | ||||||
|                     try: |  | ||||||
|                         homework_4 = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/div/ul/li/p"))) |  | ||||||
|                         print(homework_4.text()) |  | ||||||
|                         try: |  | ||||||
|                             homework_5 = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/div/ul/li/p"))) |  | ||||||
|                             print(homework_5.text()) |  | ||||||
|                         except: |  | ||||||
|                             print("Homework 5 not found") |  | ||||||
|                             WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]/svg"))).click() # Click on next day button |  | ||||||
|                             next_homework += 1 |  | ||||||
|                             check_homework() |  | ||||||
|                     except: |  | ||||||
|                         print("Homework 4 not found") |  | ||||||
|                         WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]/svg"))).click() # Click on next day button |  | ||||||
|                         next_homework += 1 |  | ||||||
|                         check_homework() |  | ||||||
|                 except: |  | ||||||
|                     print("Homework 3 not found") |  | ||||||
|                     WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]/svg"))).click() # Click on next day button |  | ||||||
|                     next_homework += 1 |  | ||||||
|                     check_homework() |  | ||||||
|             except: |  | ||||||
|                 print("Homework 2 not found") |  | ||||||
|                 WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]/svg"))).click() # Click on next day button |  | ||||||
|                 next_homework += 1 |  | ||||||
|                 check_homework() |  | ||||||
|         except: |  | ||||||
|             print("No homework") |  | ||||||
|             WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]/svg"))).click() # Click on next day button |  | ||||||
|             next_homework += 1 |  | ||||||
|             check_homework() |  | ||||||
|  |  | ||||||
| #Date | #Compiti solo uno | ||||||
| # /html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[1] | # /html/body/div/div/main/div/p | ||||||
| # /html/body/div/div/main/div/div[1]/div[1]/div[1]/div[1]/button[1] |  | ||||||
|  |  | ||||||
| #Button for next day | # Compiti più di uno | ||||||
| # /html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]/svg |  | ||||||
| # /html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]/svg |  | ||||||
|  |  | ||||||
| #Compiti |  | ||||||
| # /html/body/div/div/main/div/div[2]/div/ul/li[1]/div/ul/li/p | # /html/body/div/div/main/div/div[2]/div/ul/li[1]/div/ul/li/p | ||||||
| # /html/body/div/div/main/div/div[2]/div/ul/li[2]/div/ul/li/p | # /html/body/div/div/main/div/div[2]/div/ul/li[2]/div/ul/li/p | ||||||
| # /html/body/div/div/main/div/div[2]/div/ul/li[1]/div/ul/li/p |  | ||||||
|  |  | ||||||
| #Se non ci sono compiti | # Giorno dopo | ||||||
| # /html/body/div/div/main/div/p | # /html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3] | ||||||
		Reference in New Issue
	
	Block a user