From 8ed0d68179d291b5667d69bb4dd364bc59edd195 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 13 Jan 2022 23:07:30 +0100 Subject: [PATCH] improved typing --- main.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index fcf4aec..6b69916 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,9 @@ from sys import argv -from requests_html import BaseSession as Session -from bs4 import BeautifulSoup +from requests_html import BaseSession, HTMLResponse +from bs4 import BeautifulSoup # Peut-être retiré par les fonctions de requests_html ? class Universite: - def __init__(self, url, pseudo, motDePasse): + def __init__(self, url: str, pseudo: str, motDePasse: str): self.url = url self.loginData = { "username": pseudo, @@ -12,18 +12,18 @@ class Universite: "submit": "SE CONNECTER" } - def maSoupe(self, page): - """Macro qui utilise le parser HTML de bs4.""" + def maSoupe(self, page: HTMLResponse): + """Macro pour utiliser le parser HTML de bs4.""" return BeautifulSoup(page.content, "html.parser") - def ecrirePageHTML(self, texte): + def ecrirePageHTML(self, texte: str): """Affiche la page HTML pour le debug.""" with open("page.html", 'w') as f: f.write(texte) - def recuperationNotes(self): + def recuperationNotes(self) -> str: """Récupère les notes.""" - with Session() as session: + with BaseSession() as session: # login reponse = session.get(self.url) soup = self.maSoupe(reponse)