improved typing
This commit is contained in:
parent
9046bee352
commit
8ed0d68179
1 changed files with 8 additions and 8 deletions
16
main.py
16
main.py
|
@ -1,9 +1,9 @@
|
||||||
from sys import argv
|
from sys import argv
|
||||||
from requests_html import BaseSession as Session
|
from requests_html import BaseSession, HTMLResponse
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup # Peut-être retiré par les fonctions de requests_html ?
|
||||||
|
|
||||||
class Universite:
|
class Universite:
|
||||||
def __init__(self, url, pseudo, motDePasse):
|
def __init__(self, url: str, pseudo: str, motDePasse: str):
|
||||||
self.url = url
|
self.url = url
|
||||||
self.loginData = {
|
self.loginData = {
|
||||||
"username": pseudo,
|
"username": pseudo,
|
||||||
|
@ -12,18 +12,18 @@ class Universite:
|
||||||
"submit": "SE CONNECTER"
|
"submit": "SE CONNECTER"
|
||||||
}
|
}
|
||||||
|
|
||||||
def maSoupe(self, page):
|
def maSoupe(self, page: HTMLResponse):
|
||||||
"""Macro qui utilise le parser HTML de bs4."""
|
"""Macro pour utiliser le parser HTML de bs4."""
|
||||||
return BeautifulSoup(page.content, "html.parser")
|
return BeautifulSoup(page.content, "html.parser")
|
||||||
|
|
||||||
def ecrirePageHTML(self, texte):
|
def ecrirePageHTML(self, texte: str):
|
||||||
"""Affiche la page HTML pour le debug."""
|
"""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) -> str:
|
||||||
"""Récupère les notes."""
|
"""Récupère les notes."""
|
||||||
with Session() as session:
|
with BaseSession() as session:
|
||||||
# login
|
# login
|
||||||
reponse = session.get(self.url)
|
reponse = session.get(self.url)
|
||||||
soup = self.maSoupe(reponse)
|
soup = self.maSoupe(reponse)
|
||||||
|
|
Reference in a new issue