bain3 / pronotepy

A python API wrapper for pronote
MIT License
189 stars 55 forks source link

PronotePy API Error : pronotepy.exceptions.PronoteAPIError: Your IP address is suspended. #291

Closed TotoCodeFR closed 8 months ago

TotoCodeFR commented 11 months ago

Hello,

I recently decided to make a WhatsApp bot that gets my class' homework and send it to our group. The problem is that it gives me this error : pronotepy.exceptions.PronoteAPIError: Your IP address is suspended.. I do not know why. My used code is below:

import requests
import pronotepy
from pronotepy.ent import ac_poitiers

# creating the client and passing the occitanie_montpellier function to automatically get cookies from ENT
client = pronotepy.Client('https://HIDING_MY_SCHOOL'S_ID.index-education.net/pronote/eleve.html',
                          username='HIDING_MY_USERNAME',
                          password='HIDING_MY_PASSWORD',
                          ent=ac_poitiers)

if client.logged_in: # check if client successfully logged in
    # get the all the periods (may return multiple types like trimesters and semesters but it doesn't really matter
    # the api will get it anyway)
    nom_utilisateur = client.info.name # get users name
    print(f'Logged in as {nom_utilisateur}')

    today = datetime.date.today() # store today's date using datetime built-in library
    homework = client.homework(today) # get list of homework for today and later

    for hw in homework: # iterate through the list
        print(f"({hw.subject.name}): {hw.description}") # print the homework's subject, title and description

else: 
    print("Failed to log in")

I would like to get help. Thanks.

P-S : I removed the WhatsApp part, my username, password and school id from this script.

V3NCO commented 10 months ago

I guess your bot just did too much requests in a certain period of time, so your ip is now suspended by pronote, try to login normally via browser and see if you can login (from the same device where your code is hosted) to see if it works or not, if it doesnt, then you can't do anything about it other that using a vpn or changing the host (it may be ip banned later if you continue doing that much requests)

TotoCodeFR commented 10 months ago

Yeah, but my bot just comes, get the homework, prints it and dip out, so why would it send that much requests?

tarneaux commented 10 months ago

How often (i.e. at which frequency) does it run?

TotoCodeFR commented 10 months ago

Like, twice a week? And I haven't touched it in a month because it's not fully functionnal... The WhatsApp part is functionnal, but because of this, it doesn't.

V3NCO commented 10 months ago

Okay if its only twice a week it is weird, i can't really help you here, good luck !

tarneaux commented 10 months ago

Can you try connecting with another IP (i.e. from another wifi network, through a VPN or after rebooting your router if you have a dynamic public IP) to see if the issue persists? Do you still have access to pronote through a web browser?

TotoCodeFR commented 10 months ago

I kinda don't want to test it because: Other WiFi network : My computer is on ethernet and doesn't have any WiFi card. VPN : I don't want to install one just for this Rebooting router : Don't have dynamic public IP