Adding a skeleton
This commit is contained in:
parent
eb4a5d414d
commit
081402832b
1 changed files with 30 additions and 16 deletions
46
main.py
46
main.py
|
@ -19,8 +19,8 @@ class Universite:
|
|||
with open("page.html", 'w') as f:
|
||||
f.write(texte)
|
||||
|
||||
def recuperationNotes(self) -> str:
|
||||
"""Récupère les notes."""
|
||||
def recuperationNotes(self) -> dict:
|
||||
"""Récupère les notes sous forme d'un dictionnaire."""
|
||||
with BaseSession() as session:
|
||||
reponse = session.get(self.url)
|
||||
|
||||
|
@ -41,31 +41,45 @@ class Universite:
|
|||
# choix des années
|
||||
url = f"{url}?{[element.attrs['action'] for element in reponse.html.find('form') if 'enctype' in element.attrs if element.attrs['enctype'] == 'application/x-www-form-urlencoded'][0].split('?')[1].replace('welcome', 'notes')}"
|
||||
reponse = session.get(url)
|
||||
self.ecrirePageHTML(reponse.text)
|
||||
|
||||
# page des notes
|
||||
# TODO
|
||||
|
||||
# récupération tableaux des notes
|
||||
""" soup = self.maSoupe(reponse)
|
||||
for attrs in soup.findAll("table"):
|
||||
try:
|
||||
texte = str(attrs).split("thead")[1][2:-2]
|
||||
while " " in texte:
|
||||
texte = texte.replace(" ", ' ')
|
||||
return texte
|
||||
except:
|
||||
pass """
|
||||
return "WIP"
|
||||
return self.stringVersDictNotes(reponse.text)
|
||||
|
||||
def stringVersDictNotes(self, html: str) -> dict:
|
||||
"""Récupère la page HTML contenant les notes et renvoie un dictionnaire."""
|
||||
self.ecrirePageHTML(html)
|
||||
|
||||
# récupération tableaux des notes
|
||||
""" soup = self.maSoupe(reponse)
|
||||
for attrs in soup.findAll("table"):
|
||||
try:
|
||||
texte = str(attrs).split("thead")[1][2:-2]
|
||||
while " " in texte:
|
||||
texte = texte.replace(" ", ' ')
|
||||
return texte
|
||||
except:
|
||||
pass """
|
||||
|
||||
return {"WIP": None}
|
||||
|
||||
def affichageNotes(self, notes: dict) -> str:
|
||||
"""Renvoie un jolie tableau avec les notes"""
|
||||
return str(notes)
|
||||
|
||||
def notes(self):
|
||||
"""Affiche les notes dans stdout."""
|
||||
print(self.affichageNotes(self.recuperationNotes()))
|
||||
|
||||
if __name__ == "__main__":
|
||||
nom = argv.pop(0)
|
||||
if len(argv) == 3:
|
||||
print(Universite(*argv).recuperationNotes())
|
||||
Universite(*argv).notes()
|
||||
else:
|
||||
load_dotenv()
|
||||
try:
|
||||
print(Universite(environ["URL"], environ["LOGIN"], environ["PASSWORD"]).recuperationNotes())
|
||||
Universite(environ["URL"], environ["LOGIN"], environ["PASSWORD"]).notes()
|
||||
except:
|
||||
print(f"""Merci de renseigner l'URL, le pseudo et le mot de passe (avec des \"). \
|
||||
\n-> python3 {nom} "URL" "pseudo" "mot-de-passe" \
|
||||
|
|
Reference in a new issue