Compare commits

...

3 Commits

Author SHA1 Message Date
Stefano Assenzo 4fcfa71b49 Add library on requirements.txt 2023-01-13 20:45:26 +00:00
Stefano Assenzo 85c669be38 Delete my test file (ops i accidently upload the file with the other commit) 2023-01-13 20:39:37 +00:00
Stefano Assenzo 092e3c4f84 New structure JSON for DB and split date (no current test) 2023-01-13 20:37:18 +00:00
3 changed files with 31 additions and 18 deletions

View File

@ -0,0 +1,9 @@
pymongo==4.3.3
python-dotenv==0.21.0
selenium==4.7.2
imbox==0.9.8
openpyxl==3.0.10
python-dotenv==0.21.0
Flask==2.2.2
requests==2.28.1
python_bcrypt==0.3.2

View File

@ -9,6 +9,7 @@ from selenium import webdriver
# Libraries for MongoDB and .env file
from dotenv import load_dotenv
import urllib.parse
import datetime
import pymongo
import os
@ -32,14 +33,28 @@ def giorno_cinque():
#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 = {
"Date": date,
"School Subject": "No school subject",
"Description": description,
}
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
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

View File

@ -18,16 +18,5 @@ app = Flask(__name__)
def get_homework():
homework = collection.find({}, {"_id": 0})
return jsonify(list(homework))
if __name__ == '__main__':
app.run()
#{
# "date": {
# "day": 12,
# "month": 1,
# "year": 2023
# },
# "description": "Per le vacanze di natale...",
# "subject": "Disegno"
#}
app.run()