bain3/pronotepy

can't instantiate a connection as described in PROTOCOL.md

Closed this issue · 3 comments

I follow the protocol in Pronote_protocal.md, but it returns a 500 error :

import requests
from bs4 import BeautifulSoup

def getNumeroOrdre(number):
    # I don't know how to encode :) so this works with the first only
    return ["3fa959b13967e0ef176069e01e23c8d7"][number]

firstRequest = BeautifulSoup(requests.get("https://0311582b.index-education.net/pronote/eleve.html", headers={"user-agent": "Mozilla/5.0 (iPad; CPU OS 15_7_8 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148  PRONOTE Mobile APP Version/0.1.58", "cookie": "appliMobile=1; ielang=1036"}).text, features="html.parser")
sessionID = int(firstRequest.select_one("html body").get_attribute_list("onload")[0].split("try { Start ({h:'")[1].split("',sCrA:")[0])

print(requests.post(
    "https://0311582b.index-education.net/pronote/appelfonction/6/"+str(sessionID)+"/"+getNumeroOrdre(0),
    data={
            "nom": "FonctionParametres",
            "session": str(sessionID),
            "numeroOrdre": getNumeroOrdre(0),
            "donneesSec": {
                "donnees": {
                    "Uuid": "wevb/vtsMcSO7cJ3rwxysQ=="
                }
            }
        }
))
print(sessionID)

I wrote this code cause the librairy did not work.
Can you help me ?

Hey, looking at the link for your pronote instance, it seems like you need to connect with the Haute-Garonne CAS. If you're trying to do a raw pronote login it will probably not work. (This may hypothetically be in the protocol file somewhere)

Also, do know that naming your issues things like "why my code don't work" will make your issue less likely to get a good response. Try renaming it to something that describes your problem better, like "can't instantiate a connection as described in PROTOCOL.md". Some maintainers will actually just close your issue, and sometimes even ban you from the repo if they see issues named this way.

Judging from the fact that you are a pronote user, I'll make a wild guess: you're french (like me). As I've seen in 6 months of watching this repo's issues, PRs etc. is that bain and others reply in english to french messages (since bain, for example, is czech). If you don't speak english very well don't force yourself, looking at this issue I'd say it would be more understandable in french.

Anyway apart from this I'm helpless and you'll have to wait for someone else to respond, which might take more or less time depending on the issue's title ;-)

Yès, aïe now mi angliche isent' verie good, beute dats ok aïe finque cauze aïe am Freinche, you now ? (🥖🥖🥖🥖 Baguette Paris Et voilà ! 🥖🥖🥖🥖)

Je vais essayer de mieux regarder dans protocol.md pour voir si je n'obtiens pas de réponse.
J'ai aussi changé le titre, comme vous pouvez le voir...

I'll try to look better in the protocol to see if I don't get an answer.
I also changed the title, as you can see

Merci pour votre réponse rapide.

bain3 commented

Tarneo is right, you should connect using the ecollege_haute_garonne_edu ENT function (ENT documentation).

The session field in the FonctionParametres request is an int (as indicated by the comment next to the value in the PRONOTE protocol document). That's probably why you're getting the 500 http response.

I really think using pronotepy will be easier than implementing the whole thing yourself, though.