Compare commits
2 Commits
4fcfa71b49
...
fef82d882d
Author | SHA1 | Date |
---|---|---|
Stefano Assenzo | fef82d882d | |
Stefano Assenzo | e4a7000399 |
|
@ -1,4 +1,5 @@
|
||||||
test.xlsx
|
test.xlsx
|
||||||
.env
|
.env
|
||||||
geckodriver.log
|
geckodriver.log
|
||||||
all.log
|
all.log
|
||||||
|
__pycache__
|
|
@ -1,33 +0,0 @@
|
||||||
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,7 +1,9 @@
|
||||||
|
# Import file for check homework
|
||||||
|
from day_one import day_one
|
||||||
|
|
||||||
# Libraries for open and use Firefox
|
# Libraries for open and use Firefox
|
||||||
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.firefox.options import Options
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
|
@ -9,12 +11,11 @@ from selenium import webdriver
|
||||||
# Libraries for MongoDB and .env file
|
# Libraries for MongoDB and .env file
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import datetime
|
|
||||||
import pymongo
|
import pymongo
|
||||||
import os
|
import os
|
||||||
|
|
||||||
#Load .env file
|
#Load .env file
|
||||||
load_dotenv()
|
load_dotenv() #Load .env file
|
||||||
USERNAME = os.getenv('USERNAME_NUVOLA') #Username for Nuvola
|
USERNAME = os.getenv('USERNAME_NUVOLA') #Username for Nuvola
|
||||||
PASSWORD = os.getenv('PASSWORD_NUVOLA') #Password for Nuvola
|
PASSWORD = os.getenv('PASSWORD_NUVOLA') #Password for Nuvola
|
||||||
PASSWORD_MONGODB = os.getenv('PASSWORD_MONGODB') #Password for MongoDB
|
PASSWORD_MONGODB = os.getenv('PASSWORD_MONGODB') #Password for MongoDB
|
||||||
|
@ -24,482 +25,14 @@ client = pymongo.MongoClient(mongo_url) #Connect to MongoDB
|
||||||
database = client["website-class"] #Database name
|
database = client["website-class"] #Database name
|
||||||
collection = database["homework"] #Collection school time table current
|
collection = database["homework"] #Collection school time table current
|
||||||
|
|
||||||
options = Options()
|
# Options for Firefox
|
||||||
|
options = Options() # Set 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
|
|
||||||
|
|
||||||
def giorno_cinque():
|
def start_search():
|
||||||
#Giorno cinque
|
global driver
|
||||||
try:
|
driver = webdriver.Firefox(options=options) # Open Firefox and set options
|
||||||
date = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[1]"))).text) # Date
|
|
||||||
split_date = date.split() # Split date
|
|
||||||
description = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) # Homework 1 or no homework
|
|
||||||
mydict = {
|
|
||||||
"subjects": [
|
|
||||||
{
|
|
||||||
"name": "No school subject",
|
|
||||||
"homework": [
|
|
||||||
{
|
|
||||||
"date": {
|
|
||||||
"day": split_date[0],
|
|
||||||
"month": split_date[1],
|
|
||||||
"year": split_date[2],
|
|
||||||
},
|
|
||||||
"description": description,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
x = collection.insert_many(mydict) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li/h2"))).text) # School subject 1
|
|
||||||
new_school_subject = {"$set": {"School Subject": school_subject}} # Update school subject
|
|
||||||
collection.update_one(mydict, new_school_subject) # Update school subject
|
|
||||||
try:
|
|
||||||
school_subject_1 = str(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) # School subject 1
|
|
||||||
description_1 = str(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) # Homework 1
|
|
||||||
mydict1 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_1,
|
|
||||||
"Description": description_1,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict1) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
|
||||||
description_2 = str(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) # Homework 2
|
|
||||||
mydict2 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_2,
|
|
||||||
"Description": description_2,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict2) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
|
||||||
description_3 = str(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) # Homework 3
|
|
||||||
mydict3 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_3,
|
|
||||||
"Description": description_3,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict3) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
|
||||||
description_4 = str(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) # Homework 4
|
|
||||||
mydict4 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_4,
|
|
||||||
"Description": description_4,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict4) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
|
||||||
description_5 = str(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) # Homework 5
|
|
||||||
mydict5 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_5,
|
|
||||||
"Description": description_5,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict5) # Insert data in MongoDB
|
|
||||||
|
|
||||||
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() # Click on next day button
|
|
||||||
driver.close()
|
|
||||||
except TimeoutException:
|
|
||||||
try:
|
|
||||||
school_subject_1 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/h2"))).text) # School subject 1
|
|
||||||
description_1 = str(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) # Homework 1
|
|
||||||
mydict6 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_1,
|
|
||||||
"Description": description_1,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict6) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
|
||||||
description_2 = str(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) # Homework 2
|
|
||||||
mydict7 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_2,
|
|
||||||
"Description": description_2,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict7) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
|
||||||
description_3 = str(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) # Homework 3
|
|
||||||
mydict8 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_3,
|
|
||||||
"Description": description_3,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict8) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
|
||||||
description_4 = str(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) # Homework 4
|
|
||||||
mydict9 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_4,
|
|
||||||
"Description": description_4,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict9) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
|
||||||
description_5 = str(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) # Homework 5
|
|
||||||
mydict10 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_5,
|
|
||||||
"Description": description_5,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict10) # Insert data in MongoDB
|
|
||||||
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() # Click on next day button
|
|
||||||
driver.close()
|
|
||||||
|
|
||||||
def giorno_quattro():
|
|
||||||
#Giorno quattro
|
|
||||||
try:
|
|
||||||
date = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[1]"))).text) # Date
|
|
||||||
description = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) # Homework 1 or no homework
|
|
||||||
mydict = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": "No school subject",
|
|
||||||
"Description": description,
|
|
||||||
}
|
|
||||||
|
|
||||||
x = collection.insert_one(mydict) # Insert data in MongoDB
|
|
||||||
school_subject = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li/h2"))).text) # School subject 1
|
|
||||||
new_school_subject = {"$set": {"School Subject": school_subject}} # Update school subject
|
|
||||||
collection.update_one(mydict, new_school_subject) # Update school subject
|
|
||||||
try:
|
|
||||||
school_subject_1 = str(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) # School subject 1
|
|
||||||
description_1 = str(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) # Homework 1
|
|
||||||
mydict1 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_1,
|
|
||||||
"Description": description_1,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict1) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
|
||||||
description_2 = str(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) # Homework 2
|
|
||||||
mydict2 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_2,
|
|
||||||
"Description": description_2,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict2) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
|
||||||
description_3 = str(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) # Homework 3
|
|
||||||
mydict3 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_3,
|
|
||||||
"Description": description_3,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict3) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
|
||||||
description_4 = str(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) # Homework 4
|
|
||||||
mydict4 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_4,
|
|
||||||
"Description": description_4,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict4) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
|
||||||
description_5 = str(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) # Homework 5
|
|
||||||
mydict5 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_5,
|
|
||||||
"Description": description_5,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict5) # Insert data in MongoDB
|
|
||||||
|
|
||||||
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() # Click on next day button
|
|
||||||
giorno_cinque()
|
|
||||||
except TimeoutException:
|
|
||||||
try:
|
|
||||||
school_subject_1 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/h2"))).text) # School subject 1
|
|
||||||
description_1 = str(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) # Homework 1
|
|
||||||
mydict6 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_1,
|
|
||||||
"Description": description_1,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict6) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
|
||||||
description_2 = str(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) # Homework 2
|
|
||||||
mydict7 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_2,
|
|
||||||
"Description": description_2,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict7) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
|
||||||
description_3 = str(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) # Homework 3
|
|
||||||
mydict8 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_3,
|
|
||||||
"Description": description_3,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict8) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
|
||||||
description_4 = str(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) # Homework 4
|
|
||||||
mydict9 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_4,
|
|
||||||
"Description": description_4,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict9) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
|
||||||
description_5 = str(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) # Homework 5
|
|
||||||
mydict10 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_5,
|
|
||||||
"Description": description_5,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict10) # Insert data in MongoDB
|
|
||||||
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() # Click on next day button
|
|
||||||
giorno_cinque()
|
|
||||||
|
|
||||||
def giorno_tre():
|
|
||||||
#Giorno tre
|
|
||||||
try:
|
|
||||||
date = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[1]"))).text) # Date
|
|
||||||
description = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) # Homework 1 or no homework
|
|
||||||
mydict = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": "No school subject",
|
|
||||||
"Description": description,
|
|
||||||
}
|
|
||||||
|
|
||||||
x = collection.insert_one(mydict) # Insert data in MongoDB
|
|
||||||
school_subject = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li/h2"))).text) # School subject 1
|
|
||||||
new_school_subject = {"$set": {"School Subject": school_subject}} # Update school subject
|
|
||||||
collection.update_one(mydict, new_school_subject) # Update school subject
|
|
||||||
try:
|
|
||||||
school_subject_1 = str(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) # School subject 1
|
|
||||||
description_1 = str(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) # Homework 1
|
|
||||||
mydict1 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_1,
|
|
||||||
"Description": description_1,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict1) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
|
||||||
description_2 = str(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) # Homework 2
|
|
||||||
mydict2 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_2,
|
|
||||||
"Description": description_2,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict2) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
|
||||||
description_3 = str(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) # Homework 3
|
|
||||||
mydict3 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_3,
|
|
||||||
"Description": description_3,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict3) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
|
||||||
description_4 = str(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) # Homework 4
|
|
||||||
mydict4 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_4,
|
|
||||||
"Description": description_4,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict4) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
|
||||||
description_5 = str(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) # Homework 5
|
|
||||||
mydict5 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_5,
|
|
||||||
"Description": description_5,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict5) # Insert data in MongoDB
|
|
||||||
|
|
||||||
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() # Click on next day button
|
|
||||||
giorno_quattro()
|
|
||||||
except TimeoutException:
|
|
||||||
try:
|
|
||||||
school_subject_1 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/h2"))).text) # School subject 1
|
|
||||||
description_1 = str(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) # Homework 1
|
|
||||||
mydict6 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_1,
|
|
||||||
"Description": description_1,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict6) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
|
||||||
description_2 = str(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) # Homework 2
|
|
||||||
mydict7 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_2,
|
|
||||||
"Description": description_2,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict7) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
|
||||||
description_3 = str(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) # Homework 3
|
|
||||||
mydict8 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_3,
|
|
||||||
"Description": description_3,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict8) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
|
||||||
description_4 = str(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) # Homework 4
|
|
||||||
mydict9 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_4,
|
|
||||||
"Description": description_4,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict9) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
|
||||||
description_5 = str(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) # Homework 5
|
|
||||||
mydict10 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_5,
|
|
||||||
"Description": description_5,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict10) # Insert data in MongoDB
|
|
||||||
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() # Click on next day button
|
|
||||||
giorno_quattro()
|
|
||||||
|
|
||||||
def giorno_due():
|
|
||||||
#Giorno due
|
|
||||||
try:
|
|
||||||
date = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[1]"))).text) # Date
|
|
||||||
description = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) # Homework 1 or no homework
|
|
||||||
mydict = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": "No school subject",
|
|
||||||
"Description": description,
|
|
||||||
}
|
|
||||||
|
|
||||||
x = collection.insert_one(mydict) # Insert data in MongoDB
|
|
||||||
school_subject = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li/h2"))).text) # School subject 1
|
|
||||||
new_school_subject = {"$set": {"School Subject": school_subject}} # Update school subject
|
|
||||||
collection.update_one(mydict, new_school_subject) # Update school subject
|
|
||||||
try:
|
|
||||||
school_subject_1 = str(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) # School subject 1
|
|
||||||
description_1 = str(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) # Homework 1
|
|
||||||
mydict1 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_1,
|
|
||||||
"Description": description_1,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict1) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
|
||||||
description_2 = str(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) # Homework 2
|
|
||||||
mydict2 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_2,
|
|
||||||
"Description": description_2,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict2) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
|
||||||
description_3 = str(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) # Homework 3
|
|
||||||
mydict3 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_3,
|
|
||||||
"Description": description_3,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict3) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
|
||||||
description_4 = str(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) # Homework 4
|
|
||||||
mydict4 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_4,
|
|
||||||
"Description": description_4,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict4) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
|
||||||
description_5 = str(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) # Homework 5
|
|
||||||
mydict5 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_5,
|
|
||||||
"Description": description_5,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict5) # Insert data in MongoDB
|
|
||||||
|
|
||||||
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() # Click on next day button
|
|
||||||
giorno_tre()
|
|
||||||
except TimeoutException:
|
|
||||||
try:
|
|
||||||
school_subject_1 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/h2"))).text) # School subject 1
|
|
||||||
description_1 = str(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) # Homework 1
|
|
||||||
mydict6 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_1,
|
|
||||||
"Description": description_1,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict6) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
|
||||||
description_2 = str(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) # Homework 2
|
|
||||||
mydict7 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_2,
|
|
||||||
"Description": description_2,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict7) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
|
||||||
description_3 = str(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) # Homework 3
|
|
||||||
mydict8 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_3,
|
|
||||||
"Description": description_3,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict8) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
|
||||||
description_4 = str(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) # Homework 4
|
|
||||||
mydict9 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_4,
|
|
||||||
"Description": description_4,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict9) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
|
||||||
description_5 = str(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) # Homework 5
|
|
||||||
mydict10 = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_5,
|
|
||||||
"Description": description_5,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict10) # Insert data in MongoDB
|
|
||||||
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() # Click on next day button
|
|
||||||
giorno_tre()
|
|
||||||
|
|
||||||
def giorno_uno():
|
|
||||||
driver.get("https://nuvola.madisoft.it/login") # Open Nuvola website
|
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
|
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
|
password = WebDriverWait(driver, 100).until(EC.element_to_be_clickable((By.ID, "password"))) # Wait for the password input
|
||||||
|
@ -514,136 +47,12 @@ def giorno_uno():
|
||||||
|
|
||||||
# Section Homework
|
# Section Homework
|
||||||
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
|
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
|
||||||
|
homework_check()
|
||||||
|
|
||||||
|
def homework_check():
|
||||||
#Giorno uno
|
#Giorno uno
|
||||||
try:
|
day_five.giorno_cinque(driver, collection)
|
||||||
date = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[1]"))).text) # Date
|
driver.close()
|
||||||
description = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) # Homework 1 or no homework
|
start_search()
|
||||||
mydict = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": "No school subject",
|
|
||||||
"Description": description,
|
|
||||||
}
|
|
||||||
|
|
||||||
x = collection.insert_one(mydict) # Insert data in MongoDB
|
start_search()
|
||||||
school_subject = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li/h2"))).text) # School subject 1
|
|
||||||
new_school_subject = {"$set": {"School Subject": school_subject}} # Update school subject
|
|
||||||
collection.update_one(mydict, new_school_subject) # Update school subject
|
|
||||||
try:
|
|
||||||
school_subject_1 = str(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) # School subject 1
|
|
||||||
description_1 = str(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) # Homework 1
|
|
||||||
mydict = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_1,
|
|
||||||
"Description": description_1,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
|
||||||
description_2 = str(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) # Homework 2
|
|
||||||
mydict = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_2,
|
|
||||||
"Description": description_2,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
|
||||||
description_3 = str(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) # Homework 3
|
|
||||||
mydict = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_3,
|
|
||||||
"Description": description_3,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
|
||||||
description_4 = str(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) # Homework 4
|
|
||||||
mydict = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_4,
|
|
||||||
"Description": description_4,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
|
||||||
description_5 = str(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) # Homework 5
|
|
||||||
mydict = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_5,
|
|
||||||
"Description": description_5,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict) # Insert data in MongoDB
|
|
||||||
|
|
||||||
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() # Click on next day button
|
|
||||||
giorno_due()
|
|
||||||
except TimeoutException:
|
|
||||||
try:
|
|
||||||
school_subject_1 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/h2"))).text) # School subject 1
|
|
||||||
description_1 = str(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) # Homework 1
|
|
||||||
mydict = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_1,
|
|
||||||
"Description": description_1,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
|
||||||
description_2 = str(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) # Homework 2
|
|
||||||
mydict = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_2,
|
|
||||||
"Description": description_2,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
|
||||||
description_3 = str(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) # Homework 3
|
|
||||||
mydict = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_3,
|
|
||||||
"Description": description_3,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
|
||||||
description_4 = str(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) # Homework 4
|
|
||||||
mydict = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_4,
|
|
||||||
"Description": description_4,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict) # Insert data in MongoDB
|
|
||||||
|
|
||||||
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
|
||||||
description_5 = str(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) # Homework 5
|
|
||||||
mydict = {
|
|
||||||
"Date": date,
|
|
||||||
"School Subject": school_subject_5,
|
|
||||||
"Description": description_5,
|
|
||||||
}
|
|
||||||
x = collection.insert_one(mydict) # Insert data in MongoDB
|
|
||||||
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() # Click on next day button
|
|
||||||
giorno_due()
|
|
||||||
|
|
||||||
giorno_uno()
|
|
||||||
|
|
||||||
#Compiti solo uno
|
|
||||||
# /html/body/div/div/main/div/p
|
|
||||||
|
|
||||||
# Compiti più di uno
|
|
||||||
# /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
|
|
||||||
|
|
||||||
# Giorno dopo
|
|
||||||
# /html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[3]
|
|
||||||
|
|
||||||
|
|
||||||
# Nome Materia solo una
|
|
||||||
# /html/body/div/div/main/div/div[2]/div/ul/li/h2
|
|
||||||
|
|
||||||
# Nome Materia più di una
|
|
||||||
# /html/body/div/div/main/div/div[2]/div/ul/li[1]/h2
|
|
||||||
# /html/body/div/div/main/div/div[2]/div/ul/li[2]/h2
|
|
|
@ -0,0 +1,261 @@
|
||||||
|
# Libraries for open and use Firefox
|
||||||
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
|
from selenium.common.exceptions import TimeoutException
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
|
||||||
|
def giorno_cinque(driver, collection):
|
||||||
|
#Giorno cinque
|
||||||
|
try:
|
||||||
|
date = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[1]"))).text) # Date
|
||||||
|
split_date = date.split() # Split date
|
||||||
|
description = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) # Homework 1 or no homework
|
||||||
|
mydict = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": "No school subject",
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li/h2"))).text) # School subject 1
|
||||||
|
new_school_subject = {"$set": {"School Subject": school_subject}} # Update school subject
|
||||||
|
collection.update_one(mydict, new_school_subject) # Update school subject
|
||||||
|
try:
|
||||||
|
school_subject_1 = str(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) # School subject 1
|
||||||
|
description_1 = str(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) # Homework 1
|
||||||
|
mydict1 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_1,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_1,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict1) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
||||||
|
description_2 = str(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) # Homework 2
|
||||||
|
mydict2 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_2,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_2,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict2) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
||||||
|
description_3 = str(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) # Homework 3
|
||||||
|
mydict3 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_3,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_3,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict3) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
||||||
|
description_4 = str(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) # Homework 4
|
||||||
|
mydict4 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_4,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_4,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict4) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
||||||
|
description_5 = str(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) # Homework 5
|
||||||
|
mydict5 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_5,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_5,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict5) # Insert data in MongoDB
|
||||||
|
|
||||||
|
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() # Click on next day button
|
||||||
|
except TimeoutException:
|
||||||
|
try:
|
||||||
|
school_subject_1 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/h2"))).text) # School subject 1
|
||||||
|
description_1 = str(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) # Homework 1
|
||||||
|
mydict6 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_1,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_1,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict6) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
||||||
|
description_2 = str(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) # Homework 2
|
||||||
|
mydict7 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_2,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_2,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict7) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
||||||
|
description_3 = str(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) # Homework 3
|
||||||
|
mydict8 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_3,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_3,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict8) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
||||||
|
description_4 = str(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) # Homework 4
|
||||||
|
mydict9 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_4,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_4,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict9) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
||||||
|
description_5 = str(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) # Homework 5
|
||||||
|
mydict10 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_5,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_5,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict10) # Insert data in MongoDB
|
||||||
|
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() # Click on next day button
|
|
@ -0,0 +1,265 @@
|
||||||
|
from day_five import day_five
|
||||||
|
|
||||||
|
# Libraries for open and use Firefox
|
||||||
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
|
from selenium.common.exceptions import TimeoutException
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
|
||||||
|
def giorno_quattro(driver, collection):
|
||||||
|
#Giorno quattro
|
||||||
|
try:
|
||||||
|
date = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[1]"))).text) # Date
|
||||||
|
split_date = date.split() # Split date
|
||||||
|
description = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) # Homework 1 or no homework
|
||||||
|
mydict = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": "No school subject",
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li/h2"))).text) # School subject 1
|
||||||
|
new_school_subject = {"$set": {"School Subject": school_subject}} # Update school subject
|
||||||
|
collection.update_one(mydict, new_school_subject) # Update school subject
|
||||||
|
try:
|
||||||
|
school_subject_1 = str(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) # School subject 1
|
||||||
|
description_1 = str(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) # Homework 1
|
||||||
|
mydict1 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_1,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_1,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict1) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
||||||
|
description_2 = str(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) # Homework 2
|
||||||
|
mydict2 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_2,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_2,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict2) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
||||||
|
description_3 = str(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) # Homework 3
|
||||||
|
mydict3 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_3,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_3,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict3) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
||||||
|
description_4 = str(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) # Homework 4
|
||||||
|
mydict4 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_4,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_4,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict4) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
||||||
|
description_5 = str(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) # Homework 5
|
||||||
|
mydict5 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_5,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_5,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict5) # Insert data in MongoDB
|
||||||
|
|
||||||
|
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() # Click on next day button
|
||||||
|
day_five.giorno_cinque(driver, collection)
|
||||||
|
except TimeoutException:
|
||||||
|
try:
|
||||||
|
school_subject_1 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/h2"))).text) # School subject 1
|
||||||
|
description_1 = str(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) # Homework 1
|
||||||
|
mydict6 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_1,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_1,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict6) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
||||||
|
description_2 = str(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) # Homework 2
|
||||||
|
mydict7 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_2,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_2,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict7) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
||||||
|
description_3 = str(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) # Homework 3
|
||||||
|
mydict8 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_3,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_3,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict8) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
||||||
|
description_4 = str(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) # Homework 4
|
||||||
|
mydict9 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_4,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_4,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict9) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
||||||
|
description_5 = str(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) # Homework 5
|
||||||
|
mydict10 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_5,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_5,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict10) # Insert data in MongoDB
|
||||||
|
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() # Click on next day button
|
||||||
|
day_five.giorno_cinque(driver, collection)
|
|
@ -0,0 +1,265 @@
|
||||||
|
from day_two import day_two
|
||||||
|
|
||||||
|
# Libraries for open and use Firefox
|
||||||
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
|
from selenium.common.exceptions import TimeoutException
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
|
||||||
|
def giorno_uno(driver, collection):
|
||||||
|
#Giorno uno
|
||||||
|
try:
|
||||||
|
date = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[1]"))).text) # Date
|
||||||
|
split_date = date.split() # Split date
|
||||||
|
description = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) # Homework 1 or no homework
|
||||||
|
mydict = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": "No school subject",
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li/h2"))).text) # School subject 1
|
||||||
|
new_school_subject = {"$set": {"name": school_subject}} # Update school subject
|
||||||
|
collection.update_one(mydict, new_school_subject) # Update school subject
|
||||||
|
try:
|
||||||
|
school_subject_1 = str(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) # School subject 1
|
||||||
|
description_1 = str(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) # Homework 1
|
||||||
|
mydict1 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_1,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_1,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict1) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
||||||
|
description_2 = str(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) # Homework 2
|
||||||
|
mydict2 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_2,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_2,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict2) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
||||||
|
description_3 = str(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) # Homework 3
|
||||||
|
mydict3 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_3,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_3,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict3) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
||||||
|
description_4 = str(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) # Homework 4
|
||||||
|
mydict4 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_4,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_4,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict4) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
||||||
|
description_5 = str(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) # Homework 5
|
||||||
|
mydict5 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_5,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_5,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict5) # Insert data in MongoDB
|
||||||
|
|
||||||
|
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() # Click on next day button
|
||||||
|
day_two.giorno_due(driver, collection)
|
||||||
|
except TimeoutException:
|
||||||
|
try:
|
||||||
|
school_subject_1 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/h2"))).text) # School subject 1
|
||||||
|
description_1 = str(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) # Homework 1
|
||||||
|
mydict6 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_1,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_1,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict6) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
||||||
|
description_2 = str(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) # Homework 2
|
||||||
|
mydict7 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_2,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_2,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict7) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
||||||
|
description_3 = str(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) # Homework 3
|
||||||
|
mydict8 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_3,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_3,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict8) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
||||||
|
description_4 = str(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) # Homework 4
|
||||||
|
mydict9 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_4,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_4,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict9) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
||||||
|
description_5 = str(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) # Homework 5
|
||||||
|
mydict10 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_5,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_5,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict10) # Insert data in MongoDB
|
||||||
|
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() # Click on next day button
|
||||||
|
day_two.giorno_due(driver, collection)
|
|
@ -0,0 +1,265 @@
|
||||||
|
from day_four import day_four
|
||||||
|
|
||||||
|
# Libraries for open and use Firefox
|
||||||
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
|
from selenium.common.exceptions import TimeoutException
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
|
||||||
|
def giorno_tre(driver, collection):
|
||||||
|
#Giorno tre
|
||||||
|
try:
|
||||||
|
date = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[1]"))).text) # Date
|
||||||
|
split_date = date.split() # Split date
|
||||||
|
description = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) # Homework 1 or no homework
|
||||||
|
mydict = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": "No school subject",
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li/h2"))).text) # School subject 1
|
||||||
|
new_school_subject = {"$set": {"School Subject": school_subject}} # Update school subject
|
||||||
|
collection.update_one(mydict, new_school_subject) # Update school subject
|
||||||
|
try:
|
||||||
|
school_subject_1 = str(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) # School subject 1
|
||||||
|
description_1 = str(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) # Homework 1
|
||||||
|
mydict1 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_1,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_1,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict1) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
||||||
|
description_2 = str(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) # Homework 2
|
||||||
|
mydict2 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_2,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_2,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict2) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
||||||
|
description_3 = str(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) # Homework 3
|
||||||
|
mydict3 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_3,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_3,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict3) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
||||||
|
description_4 = str(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) # Homework 4
|
||||||
|
mydict4 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_4,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_4,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict4) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
||||||
|
description_5 = str(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) # Homework 5
|
||||||
|
mydict5 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_5,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_5,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict5) # Insert data in MongoDB
|
||||||
|
|
||||||
|
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() # Click on next day button
|
||||||
|
day_four.giorno_quattro(driver, collection)
|
||||||
|
except TimeoutException:
|
||||||
|
try:
|
||||||
|
school_subject_1 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/h2"))).text) # School subject 1
|
||||||
|
description_1 = str(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) # Homework 1
|
||||||
|
mydict6 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_1,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_1,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict6) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
||||||
|
description_2 = str(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) # Homework 2
|
||||||
|
mydict7 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_2,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_2,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict7) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
||||||
|
description_3 = str(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) # Homework 3
|
||||||
|
mydict8 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_3,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_3,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict8) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
||||||
|
description_4 = str(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) # Homework 4
|
||||||
|
mydict9 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_4,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_4,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict9) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
||||||
|
description_5 = str(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) # Homework 5
|
||||||
|
mydict10 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_5,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_5,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict10) # Insert data in MongoDB
|
||||||
|
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() # Click on next day button
|
||||||
|
day_four.giorno_quattro(driver, collection)
|
|
@ -0,0 +1,265 @@
|
||||||
|
from day_three import day_three
|
||||||
|
|
||||||
|
# Libraries for open and use Firefox
|
||||||
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
|
from selenium.common.exceptions import TimeoutException
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
|
||||||
|
def giorno_due(driver, collection):
|
||||||
|
#Giorno due
|
||||||
|
try:
|
||||||
|
date = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div/div[1]/div[1]/div[1]/button[1]"))).text) # Date
|
||||||
|
split_date = date.split() # Split date
|
||||||
|
description = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/p"))).text) # Homework 1 or no homework
|
||||||
|
mydict = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": "No school subject",
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li/h2"))).text) # School subject 1
|
||||||
|
new_school_subject = {"$set": {"School Subject": school_subject}} # Update school subject
|
||||||
|
collection.update_one(mydict, new_school_subject) # Update school subject
|
||||||
|
try:
|
||||||
|
school_subject_1 = str(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) # School subject 1
|
||||||
|
description_1 = str(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) # Homework 1
|
||||||
|
mydict1 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_1,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_1,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict1) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
||||||
|
description_2 = str(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) # Homework 2
|
||||||
|
mydict2 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_2,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_2,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict2) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
||||||
|
description_3 = str(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) # Homework 3
|
||||||
|
mydict3 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_3,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_3,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict3) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
||||||
|
description_4 = str(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) # Homework 4
|
||||||
|
mydict4 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_4,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_5,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict4) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
||||||
|
description_5 = str(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) # Homework 5
|
||||||
|
mydict5 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_5,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_5,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict5) # Insert data in MongoDB
|
||||||
|
|
||||||
|
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() # Click on next day button
|
||||||
|
day_three.giorno_tre(driver, collection)
|
||||||
|
except TimeoutException:
|
||||||
|
try:
|
||||||
|
school_subject_1 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[1]/h2"))).text) # School subject 1
|
||||||
|
description_1 = str(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) # Homework 1
|
||||||
|
mydict6 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_1,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_1,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict6) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_2 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[2]/h2"))).text) # School subject 2
|
||||||
|
description_2 = str(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) # Homework 2
|
||||||
|
mydict7 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_2,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_2,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict7) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_3 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[3]/h2"))).text) # School subject 3
|
||||||
|
description_3 = str(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) # Homework 3
|
||||||
|
mydict8 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_3,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_3,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict8) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_4 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[4]/h2"))).text) # School subject 4
|
||||||
|
description_4 = str(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) # Homework 4
|
||||||
|
mydict9 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_4,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_4,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict9) # Insert data in MongoDB
|
||||||
|
|
||||||
|
school_subject_5 = str(WebDriverWait(driver, 250).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div/div/main/div/div[2]/div/ul/li[5]/h2"))).text) # School subject 5
|
||||||
|
description_5 = str(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) # Homework 5
|
||||||
|
mydict10 = {
|
||||||
|
"subjects": [
|
||||||
|
{
|
||||||
|
"name": school_subject_5,
|
||||||
|
"homework": [
|
||||||
|
{
|
||||||
|
"date": {
|
||||||
|
"day": split_date[0],
|
||||||
|
"month": split_date[1],
|
||||||
|
"year": split_date[2],
|
||||||
|
},
|
||||||
|
"description": description_5,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
x = collection.insert_many(mydict10) # Insert data in MongoDB
|
||||||
|
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() # Click on next day button
|
||||||
|
day_three.giorno_tre(driver, collection)
|
Loading…
Reference in New Issue