' & " crap

This commit is contained in:
Mylloon 2022-01-14 16:37:50 +01:00
parent eeb369cb50
commit 7112858874
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -32,7 +32,7 @@ class Universite:
# page des résultats intermédiaire # page des résultats intermédiaire
try: try:
url = [element.attrs["href"] for element in reponse.html.find("a") if "id" in element.attrs if element.attrs["id"] == "service-407"][0] url = [element.attrs["href"] for element in reponse.html.find('a') if "id" in element.attrs if element.attrs["id"] == "service-407"][0]
except IndexError: # Arrive quand "An Error Has Occurred" except IndexError: # Arrive quand "An Error Has Occurred"
raise TimeoutError("Le site a prit trop de temps pour répondre, veuillez réessayez plus tard.") raise TimeoutError("Le site a prit trop de temps pour répondre, veuillez réessayez plus tard.")
reponse = session.get(url, allow_redirects = False) reponse = session.get(url, allow_redirects = False)
@ -43,7 +43,8 @@ class Universite:
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)
anneesTemp = [element for element in reponse.html.find('a') if "href" in element.attrs if element.attrs["href"] == '#'][6:] anneesTemp = [element for element in reponse.html.find('a') if "href" in element.attrs if element.attrs["href"] == '#'][6:]
# on retire un item sur deux car : ['L2MINF/210', 'L2 Informatique', 'L1MINF/210', 'L1 Informatique'] il y a des doublons
# on retire un item sur deux car : ['L2MINF/210', 'L2 Informatique', 'L1MINF/210', 'L1 Informatique'] -> il y a des doublons
annees = [] annees = []
for i in range(0, len(anneesTemp)): for i in range(0, len(anneesTemp)):
if i % 2: if i % 2:
@ -53,7 +54,7 @@ class Universite:
resultat = {} resultat = {}
for annee in annees: for annee in annees:
reponse = session.post(url) reponse = session.post(url)
script = annee.attrs['onclick'][7:] script = annee.attrs["onclick"][7:]
reponse.html.render(script=script) reponse.html.render(script=script)
resultat[annee.text] = None resultat[annee.text] = None