Add comments

This commit is contained in:
Mylloon 2022-01-13 22:52:32 +01:00
parent 69d7a7d2ad
commit 3464da3c9e
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

16
main.py
View file

@ -13,13 +13,16 @@ class Universite:
} }
def maSoupe(self, page): def maSoupe(self, page):
"""Macro qui utilise le parser HTML de bs4."""
return BeautifulSoup(page.content, "html.parser") return BeautifulSoup(page.content, "html.parser")
""" def ecrirePageHTML(self, texte): # Utilisé pour du DEBUG def ecrirePageHTML(self, texte):
"""Affiche la page HTML pour le debug."""
with open("page.html", "w") as f: with open("page.html", "w") as f:
f.write(texte) """ f.write(texte)
def recuperationNotes(self): def recuperationNotes(self):
"""Récupère les notes."""
with Session() as session: with Session() as session:
# login # login
reponse = session.get(self.url) reponse = session.get(self.url)
@ -38,11 +41,14 @@ class Universite:
url = reponse.headers["Location"] url = reponse.headers["Location"]
reponse = session.get(url) reponse = session.get(url)
# page des notes # choix des années
soup = self.maSoupe(reponse) soup = self.maSoupe(reponse)
url = f"{url}?{soup.find('form', attrs = {'enctype': 'application/x-www-form-urlencoded'})['action'].split('?')[1].replace('welcome', 'detailnotes')}" url = f"{url}?{soup.find('form', attrs = {'enctype': 'application/x-www-form-urlencoded'})['action'].split('?')[1].replace('welcome', 'notes')}"
reponse = session.get(url) reponse = session.get(url)
# self.ecrirePageHTML(reponse.text) self.ecrirePageHTML(reponse.text)
# page des notes
# TODO
# récupération tableaux des notes # récupération tableaux des notes
soup = self.maSoupe(reponse) soup = self.maSoupe(reponse)