Adding a skeleton
This commit is contained in:
parent
eb4a5d414d
commit
081402832b
1 changed files with 30 additions and 16 deletions
26
main.py
26
main.py
|
@ -19,8 +19,8 @@ class Universite:
|
||||||
with open("page.html", 'w') as f:
|
with open("page.html", 'w') as f:
|
||||||
f.write(texte)
|
f.write(texte)
|
||||||
|
|
||||||
def recuperationNotes(self) -> str:
|
def recuperationNotes(self) -> dict:
|
||||||
"""Récupère les notes."""
|
"""Récupère les notes sous forme d'un dictionnaire."""
|
||||||
with BaseSession() as session:
|
with BaseSession() as session:
|
||||||
reponse = session.get(self.url)
|
reponse = session.get(self.url)
|
||||||
|
|
||||||
|
@ -41,11 +41,16 @@ class Universite:
|
||||||
# choix des années
|
# 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')}"
|
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)
|
reponse = session.get(url)
|
||||||
self.ecrirePageHTML(reponse.text)
|
|
||||||
|
|
||||||
# page des notes
|
# page des notes
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
|
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
|
# récupération tableaux des notes
|
||||||
""" soup = self.maSoupe(reponse)
|
""" soup = self.maSoupe(reponse)
|
||||||
for attrs in soup.findAll("table"):
|
for attrs in soup.findAll("table"):
|
||||||
|
@ -56,16 +61,25 @@ class Universite:
|
||||||
return texte
|
return texte
|
||||||
except:
|
except:
|
||||||
pass """
|
pass """
|
||||||
return "WIP"
|
|
||||||
|
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__":
|
if __name__ == "__main__":
|
||||||
nom = argv.pop(0)
|
nom = argv.pop(0)
|
||||||
if len(argv) == 3:
|
if len(argv) == 3:
|
||||||
print(Universite(*argv).recuperationNotes())
|
Universite(*argv).notes()
|
||||||
else:
|
else:
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
try:
|
try:
|
||||||
print(Universite(environ["URL"], environ["LOGIN"], environ["PASSWORD"]).recuperationNotes())
|
Universite(environ["URL"], environ["LOGIN"], environ["PASSWORD"]).notes()
|
||||||
except:
|
except:
|
||||||
print(f"""Merci de renseigner l'URL, le pseudo et le mot de passe (avec des \"). \
|
print(f"""Merci de renseigner l'URL, le pseudo et le mot de passe (avec des \"). \
|
||||||
\n-> python3 {nom} "URL" "pseudo" "mot-de-passe" \
|
\n-> python3 {nom} "URL" "pseudo" "mot-de-passe" \
|
||||||
|
|
Reference in a new issue