mirror of
https://github.com/assenzostefano/class-website.git
synced 2025-02-16 20:00:41 +01:00
Compare commits
3 Commits
cfb9c229f9
...
4fcfa71b49
Author | SHA1 | Date | |
---|---|---|---|
|
4fcfa71b49 | ||
|
85c669be38 | ||
|
092e3c4f84 |
@ -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
|
@ -9,6 +9,7 @@ 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
|
||||||
|
|
||||||
@ -32,14 +33,28 @@ def giorno_cinque():
|
|||||||
#Giorno cinque
|
#Giorno cinque
|
||||||
try:
|
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
|
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
|
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 = {
|
mydict = {
|
||||||
"Date": date,
|
"subjects": [
|
||||||
"School Subject": "No school subject",
|
{
|
||||||
"Description": description,
|
"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
|
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
|
new_school_subject = {"$set": {"School Subject": school_subject}} # Update school subject
|
||||||
collection.update_one(mydict, new_school_subject) # Update school subject
|
collection.update_one(mydict, new_school_subject) # Update school subject
|
||||||
|
@ -18,16 +18,5 @@ app = Flask(__name__)
|
|||||||
def get_homework():
|
def get_homework():
|
||||||
homework = collection.find({}, {"_id": 0})
|
homework = collection.find({}, {"_id": 0})
|
||||||
return jsonify(list(homework))
|
return jsonify(list(homework))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run()
|
app.run()
|
||||||
|
|
||||||
#{
|
|
||||||
# "date": {
|
|
||||||
# "day": 12,
|
|
||||||
# "month": 1,
|
|
||||||
# "year": 2023
|
|
||||||
# },
|
|
||||||
# "description": "Per le vacanze di natale...",
|
|
||||||
# "subject": "Disegno"
|
|
||||||
#}
|
|
Loading…
x
Reference in New Issue
Block a user