esprit-py 0.3.2__tar.gz → 0.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of esprit-py might be problematic. Click here for more details.
- {esprit-py-0.3.2/esprit_py.egg-info → esprit-py-0.3.4}/PKG-INFO +48 -3
- esprit-py-0.3.4/README.md +90 -0
- {esprit-py-0.3.2 → esprit-py-0.3.4}/esprit/absence.py +0 -1
- {esprit-py-0.3.2 → esprit-py-0.3.4}/esprit/auth.py +1 -0
- {esprit-py-0.3.2 → esprit-py-0.3.4}/esprit/credit.py +0 -1
- {esprit-py-0.3.2 → esprit-py-0.3.4}/esprit/esprit.py +12 -1
- esprit-py-0.3.4/esprit/grade.py +102 -0
- {esprit-py-0.3.2 → esprit-py-0.3.4}/esprit/time_schedule.py +0 -1
- esprit-py-0.3.4/esprit/utils.py +57 -0
- {esprit-py-0.3.2 → esprit-py-0.3.4/esprit_py.egg-info}/PKG-INFO +48 -3
- {esprit-py-0.3.2 → esprit-py-0.3.4}/esprit_py.egg-info/SOURCES.txt +1 -0
- {esprit-py-0.3.2 → esprit-py-0.3.4}/esprit_py.egg-info/requires.txt +2 -0
- {esprit-py-0.3.2 → esprit-py-0.3.4}/setup.py +1 -1
- esprit-py-0.3.2/README.md +0 -45
- esprit-py-0.3.2/esprit/grade.py +0 -52
- {esprit-py-0.3.2 → esprit-py-0.3.4}/LICENSE +0 -0
- {esprit-py-0.3.2 → esprit-py-0.3.4}/esprit/__init__.py +0 -0
- {esprit-py-0.3.2 → esprit-py-0.3.4}/esprit_py.egg-info/dependency_links.txt +0 -0
- {esprit-py-0.3.2 → esprit-py-0.3.4}/esprit_py.egg-info/top_level.txt +0 -0
- {esprit-py-0.3.2 → esprit-py-0.3.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: esprit-py
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: A Python library for interacting with data from esprit-tn.com
|
|
5
5
|
Home-page: https://github.com/TheLime1/esprit.py
|
|
6
6
|
Author: Lime1 (Aymen Hmani)
|
|
@@ -26,6 +26,7 @@ License-File: LICENSE
|
|
|
26
26
|
- Get your grades
|
|
27
27
|
- Get your absences
|
|
28
28
|
- Get your credits
|
|
29
|
+
- Calculate your total semester average
|
|
29
30
|
|
|
30
31
|
## Installation
|
|
31
32
|
|
|
@@ -33,13 +34,55 @@ License-File: LICENSE
|
|
|
33
34
|
pip install esprit-py
|
|
34
35
|
```
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
download `chromedriver` from [here](https://googlechromelabs.github.io/chrome-for-testing/#stable)
|
|
38
|
+
|
|
39
|
+
## Examples
|
|
40
|
+
|
|
41
|
+
get your total avreage:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from esprit import Esprit
|
|
45
|
+
|
|
46
|
+
# Replace with your actual ID and password
|
|
47
|
+
id = 'ID'
|
|
48
|
+
password = 'PASSWORD'
|
|
49
|
+
|
|
50
|
+
grades = None
|
|
51
|
+
|
|
52
|
+
# Keep trying to get grades until it is successful cuz esprit use garabage servers
|
|
53
|
+
while grades is None:
|
|
54
|
+
try:
|
|
55
|
+
# Create an Esprit object
|
|
56
|
+
esprit = Esprit(
|
|
57
|
+
driver_path="C:/path/to/chromedriver.exe")
|
|
58
|
+
|
|
59
|
+
# Attempt to log in
|
|
60
|
+
esprit.login(id, password)
|
|
61
|
+
|
|
62
|
+
# Get grades
|
|
63
|
+
grades = esprit.get_grades()
|
|
64
|
+
|
|
65
|
+
except Exception as e:
|
|
66
|
+
print(f"An error occurred: {e}. Retrying...")
|
|
67
|
+
|
|
68
|
+
if grades is not None:
|
|
69
|
+
for grade in grades:
|
|
70
|
+
print(grade)
|
|
71
|
+
else:
|
|
72
|
+
print("Failed to get grades.")
|
|
73
|
+
|
|
74
|
+
esprit.calculate_average(grades)
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
get a list of all your absences;
|
|
37
79
|
|
|
38
80
|
```python
|
|
39
81
|
from esprit import Esprit
|
|
40
82
|
|
|
41
83
|
# Create an Esprit object
|
|
42
|
-
esprit = Esprit(
|
|
84
|
+
esprit = Esprit(
|
|
85
|
+
driver_path="C:/path/to/chromedriver.exe",)
|
|
43
86
|
|
|
44
87
|
# Replace with your actual ID and password
|
|
45
88
|
id = 'ID'
|
|
@@ -58,5 +101,7 @@ if absences is not None:
|
|
|
58
101
|
print(absence)
|
|
59
102
|
else:
|
|
60
103
|
print("Failed to get absences.")
|
|
104
|
+
|
|
61
105
|
```
|
|
106
|
+
|
|
62
107
|
More examples can be found in the [examples folder](examples)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# <img src="https://esprit.tn/favicon.ico" width="28px" /> esprit-py
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> Please note that this library is not an official API provided by Esprit and is intended for educational and personal use only.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- Get your exact timetable pdf *not 300 pages pdf*
|
|
9
|
+
- Get your grades
|
|
10
|
+
- Get your absences
|
|
11
|
+
- Get your credits
|
|
12
|
+
- Calculate your total semester average
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install esprit-py
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
download `chromedriver` from [here](https://googlechromelabs.github.io/chrome-for-testing/#stable)
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
get your total avreage:
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from esprit import Esprit
|
|
28
|
+
|
|
29
|
+
# Replace with your actual ID and password
|
|
30
|
+
id = 'ID'
|
|
31
|
+
password = 'PASSWORD'
|
|
32
|
+
|
|
33
|
+
grades = None
|
|
34
|
+
|
|
35
|
+
# Keep trying to get grades until it is successful cuz esprit use garabage servers
|
|
36
|
+
while grades is None:
|
|
37
|
+
try:
|
|
38
|
+
# Create an Esprit object
|
|
39
|
+
esprit = Esprit(
|
|
40
|
+
driver_path="C:/path/to/chromedriver.exe")
|
|
41
|
+
|
|
42
|
+
# Attempt to log in
|
|
43
|
+
esprit.login(id, password)
|
|
44
|
+
|
|
45
|
+
# Get grades
|
|
46
|
+
grades = esprit.get_grades()
|
|
47
|
+
|
|
48
|
+
except Exception as e:
|
|
49
|
+
print(f"An error occurred: {e}. Retrying...")
|
|
50
|
+
|
|
51
|
+
if grades is not None:
|
|
52
|
+
for grade in grades:
|
|
53
|
+
print(grade)
|
|
54
|
+
else:
|
|
55
|
+
print("Failed to get grades.")
|
|
56
|
+
|
|
57
|
+
esprit.calculate_average(grades)
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
get a list of all your absences;
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from esprit import Esprit
|
|
65
|
+
|
|
66
|
+
# Create an Esprit object
|
|
67
|
+
esprit = Esprit(
|
|
68
|
+
driver_path="C:/path/to/chromedriver.exe",)
|
|
69
|
+
|
|
70
|
+
# Replace with your actual ID and password
|
|
71
|
+
id = 'ID'
|
|
72
|
+
password = 'PASSWORD'
|
|
73
|
+
|
|
74
|
+
# Attempt to log in
|
|
75
|
+
if esprit.login(id, password):
|
|
76
|
+
print("Login successful.")
|
|
77
|
+
else:
|
|
78
|
+
print("Login failed.")
|
|
79
|
+
|
|
80
|
+
# Get absences
|
|
81
|
+
absences = esprit.get_absences()
|
|
82
|
+
if absences is not None:
|
|
83
|
+
for absence in absences:
|
|
84
|
+
print(absence)
|
|
85
|
+
else:
|
|
86
|
+
print("Failed to get absences.")
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
More examples can be found in the [examples folder](examples)
|
|
@@ -4,6 +4,8 @@ from .grade import Grade
|
|
|
4
4
|
from .absence import Absence
|
|
5
5
|
from .time_schedule import TimeSchedule
|
|
6
6
|
from .credit import Credit
|
|
7
|
+
from .utils import Utils
|
|
8
|
+
# from .exceptions import EspritException #TODO
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
class Esprit:
|
|
@@ -11,10 +13,10 @@ class Esprit:
|
|
|
11
13
|
self.session = requests.Session()
|
|
12
14
|
self.auth = Auth(driver_path, driver, debug, headless)
|
|
13
15
|
self.grade_scrape = Grade(self.session)
|
|
14
|
-
self.grade_scrape = Grade(self.session)
|
|
15
16
|
self.absence_scrape = Absence(self.session)
|
|
16
17
|
self.time_schedule_scrape = TimeSchedule(self.session)
|
|
17
18
|
self.credit = Credit(self.session)
|
|
19
|
+
self.utils = Utils(self.session)
|
|
18
20
|
|
|
19
21
|
def login(self, username, password):
|
|
20
22
|
cookies = self.auth.login(username, password)
|
|
@@ -24,6 +26,9 @@ class Esprit:
|
|
|
24
26
|
def get_grades(self):
|
|
25
27
|
return self.grade_scrape.get_grades()
|
|
26
28
|
|
|
29
|
+
def calculate_average(self, grades):
|
|
30
|
+
return self.grade_scrape.calculate_average(grades)
|
|
31
|
+
|
|
27
32
|
def get_absences(self):
|
|
28
33
|
return self.absence_scrape.get_absences()
|
|
29
34
|
|
|
@@ -41,3 +46,9 @@ class Esprit:
|
|
|
41
46
|
|
|
42
47
|
def get_credits(self):
|
|
43
48
|
return self.credit.get_credits()
|
|
49
|
+
|
|
50
|
+
def get_student_name(self):
|
|
51
|
+
return self.utils.get_student_name()
|
|
52
|
+
|
|
53
|
+
def get_student_class(self):
|
|
54
|
+
return self.utils.get_student_class()
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
from bs4 import BeautifulSoup
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Grade:
|
|
7
|
+
"""
|
|
8
|
+
A class used to represent a Grade.
|
|
9
|
+
|
|
10
|
+
...
|
|
11
|
+
|
|
12
|
+
Attributes
|
|
13
|
+
----------
|
|
14
|
+
url : str
|
|
15
|
+
a formatted string that represents the URL of the grade page
|
|
16
|
+
session : requests.Session
|
|
17
|
+
a Session object from the requests library
|
|
18
|
+
|
|
19
|
+
Methods
|
|
20
|
+
-------
|
|
21
|
+
get_grades():
|
|
22
|
+
Returns a list of grades for the student.
|
|
23
|
+
calculate_average(grades):
|
|
24
|
+
Calculate the average grade based on the given grades.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, session):
|
|
28
|
+
self.url = "https://esprit-tn.com/ESPOnline/Etudiants/Resultat2021.aspx"
|
|
29
|
+
self.session = session
|
|
30
|
+
|
|
31
|
+
def get_grades(self):
|
|
32
|
+
"""
|
|
33
|
+
Returns a list of grades for the student.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
list
|
|
38
|
+
a list of grades, each represented as a list of strings. The first list is the headers.
|
|
39
|
+
Returns None if the page does not contain the expected text.
|
|
40
|
+
"""
|
|
41
|
+
response = self.session.get(self.url)
|
|
42
|
+
soup = BeautifulSoup(response.text, 'html.parser')
|
|
43
|
+
|
|
44
|
+
# Check if the <h1> tag with the text "Notes Des Modules" exists
|
|
45
|
+
h1_tag = soup.find('h1', text=' Notes Des Modules ')
|
|
46
|
+
if h1_tag is None:
|
|
47
|
+
print("The page does not contain the expected text.")
|
|
48
|
+
return None
|
|
49
|
+
|
|
50
|
+
table = soup.find('table', {'id': 'ContentPlaceHolder1_GridView1'})
|
|
51
|
+
rows = table.find_all('tr')
|
|
52
|
+
headers = [cell.text.strip() for cell in rows[0].find_all('th')]
|
|
53
|
+
grades = [headers] + [[cell.text.strip() for cell in row.find_all('td')]
|
|
54
|
+
for row in rows[1:]] # Skip header row
|
|
55
|
+
return grades
|
|
56
|
+
|
|
57
|
+
def calculate_average(self, grades):
|
|
58
|
+
"""
|
|
59
|
+
Calculate the average grade based on the given grades.
|
|
60
|
+
|
|
61
|
+
Parameters
|
|
62
|
+
----------
|
|
63
|
+
grades (list): A list of lists representing the grades. The first list should contain the column names.
|
|
64
|
+
|
|
65
|
+
Returns
|
|
66
|
+
-------
|
|
67
|
+
float: The calculated average grade.
|
|
68
|
+
"""
|
|
69
|
+
# Convert the list of lists to a DataFrame
|
|
70
|
+
df = pd.DataFrame(grades[1:], columns=grades[0])
|
|
71
|
+
|
|
72
|
+
# Replace empty strings with NaN
|
|
73
|
+
df.replace('', np.nan, inplace=True)
|
|
74
|
+
|
|
75
|
+
# Replace comma with dot and convert to float
|
|
76
|
+
for col in ['COEF', 'NOTE_CC', 'NOTE_TP', 'NOTE_EXAM']:
|
|
77
|
+
df[col] = df[col].str.replace(',', '.').astype(float)
|
|
78
|
+
|
|
79
|
+
# Calculate the average based on available grades
|
|
80
|
+
|
|
81
|
+
def calculate_average(row):
|
|
82
|
+
if pd.isna(row['NOTE_TP']):
|
|
83
|
+
if pd.isna(row['NOTE_CC']):
|
|
84
|
+
return row['NOTE_EXAM']
|
|
85
|
+
else:
|
|
86
|
+
return row['NOTE_EXAM'] * 0.6 + row['NOTE_CC'] * 0.4
|
|
87
|
+
elif pd.isna(row['NOTE_CC']):
|
|
88
|
+
return row['NOTE_EXAM'] * 0.8 + row['NOTE_TP'] * 0.2
|
|
89
|
+
else:
|
|
90
|
+
return row['NOTE_EXAM'] * 0.5 + row['NOTE_CC'] * 0.3 + row['NOTE_TP'] * 0.2
|
|
91
|
+
|
|
92
|
+
df['MOYENNE'] = df.apply(calculate_average, axis=1)
|
|
93
|
+
|
|
94
|
+
# Calculate the total average
|
|
95
|
+
total_average = (df['MOYENNE'] * df['COEF']).sum() / df['COEF'].sum()
|
|
96
|
+
|
|
97
|
+
# Append the total average to the DataFrame
|
|
98
|
+
df = df._append({'DESIGNATION': 'Moyenne', 'COEF': df['COEF'].sum(
|
|
99
|
+
), 'MOYENNE': total_average}, ignore_index=True)
|
|
100
|
+
|
|
101
|
+
print(df)
|
|
102
|
+
return total_average
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from bs4 import BeautifulSoup
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Utils:
|
|
5
|
+
"""
|
|
6
|
+
A utility class for interacting with the ESPRIT website.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
def __init__(self, session):
|
|
10
|
+
self.url = "https://esprit-tn.com/ESPOnline/Etudiants/Accueil.aspx"
|
|
11
|
+
self.session = session
|
|
12
|
+
|
|
13
|
+
def get_student_name(self):
|
|
14
|
+
"""
|
|
15
|
+
Get the name of the student from the ESPRIT website.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
The name of the student, or None if the name could not be found.
|
|
19
|
+
"""
|
|
20
|
+
response = self.session.get(self.url)
|
|
21
|
+
soup = BeautifulSoup(response.text, 'html.parser')
|
|
22
|
+
|
|
23
|
+
# Check if the <p> tag with the class "lead" and the string "Vous pouvez consulter dans cet espace :" exists
|
|
24
|
+
p_tag = soup.find('p', class_='lead',
|
|
25
|
+
string='Vous pouvez consulter dans cet espace :')
|
|
26
|
+
if p_tag is None:
|
|
27
|
+
print("The page does not contain the expected text.")
|
|
28
|
+
return None
|
|
29
|
+
|
|
30
|
+
span = soup.find('span', {'id': 'Label2', 'class': 'h4 text-info'})
|
|
31
|
+
if span is not None:
|
|
32
|
+
return span.text.strip()
|
|
33
|
+
else:
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
def get_student_class(self):
|
|
37
|
+
"""
|
|
38
|
+
Get the class of the student from the ESPRIT website.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
The class of the student, or None if the class could not be found.
|
|
42
|
+
"""
|
|
43
|
+
response = self.session.get(self.url)
|
|
44
|
+
soup = BeautifulSoup(response.text, 'html.parser')
|
|
45
|
+
|
|
46
|
+
# Check if the <p> tag with the class "lead" and the string "Vous pouvez consulter dans cet espace :" exists
|
|
47
|
+
p_tag = soup.find('p', class_='lead',
|
|
48
|
+
string='Vous pouvez consulter dans cet espace :')
|
|
49
|
+
if p_tag is None:
|
|
50
|
+
print("The page does not contain the expected text.")
|
|
51
|
+
return None
|
|
52
|
+
|
|
53
|
+
span = soup.find('span', {'id': 'Label3'})
|
|
54
|
+
if span is not None:
|
|
55
|
+
return span.text.strip()
|
|
56
|
+
else:
|
|
57
|
+
return None
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: esprit-py
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: A Python library for interacting with data from esprit-tn.com
|
|
5
5
|
Home-page: https://github.com/TheLime1/esprit.py
|
|
6
6
|
Author: Lime1 (Aymen Hmani)
|
|
@@ -26,6 +26,7 @@ License-File: LICENSE
|
|
|
26
26
|
- Get your grades
|
|
27
27
|
- Get your absences
|
|
28
28
|
- Get your credits
|
|
29
|
+
- Calculate your total semester average
|
|
29
30
|
|
|
30
31
|
## Installation
|
|
31
32
|
|
|
@@ -33,13 +34,55 @@ License-File: LICENSE
|
|
|
33
34
|
pip install esprit-py
|
|
34
35
|
```
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
download `chromedriver` from [here](https://googlechromelabs.github.io/chrome-for-testing/#stable)
|
|
38
|
+
|
|
39
|
+
## Examples
|
|
40
|
+
|
|
41
|
+
get your total avreage:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from esprit import Esprit
|
|
45
|
+
|
|
46
|
+
# Replace with your actual ID and password
|
|
47
|
+
id = 'ID'
|
|
48
|
+
password = 'PASSWORD'
|
|
49
|
+
|
|
50
|
+
grades = None
|
|
51
|
+
|
|
52
|
+
# Keep trying to get grades until it is successful cuz esprit use garabage servers
|
|
53
|
+
while grades is None:
|
|
54
|
+
try:
|
|
55
|
+
# Create an Esprit object
|
|
56
|
+
esprit = Esprit(
|
|
57
|
+
driver_path="C:/path/to/chromedriver.exe")
|
|
58
|
+
|
|
59
|
+
# Attempt to log in
|
|
60
|
+
esprit.login(id, password)
|
|
61
|
+
|
|
62
|
+
# Get grades
|
|
63
|
+
grades = esprit.get_grades()
|
|
64
|
+
|
|
65
|
+
except Exception as e:
|
|
66
|
+
print(f"An error occurred: {e}. Retrying...")
|
|
67
|
+
|
|
68
|
+
if grades is not None:
|
|
69
|
+
for grade in grades:
|
|
70
|
+
print(grade)
|
|
71
|
+
else:
|
|
72
|
+
print("Failed to get grades.")
|
|
73
|
+
|
|
74
|
+
esprit.calculate_average(grades)
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
get a list of all your absences;
|
|
37
79
|
|
|
38
80
|
```python
|
|
39
81
|
from esprit import Esprit
|
|
40
82
|
|
|
41
83
|
# Create an Esprit object
|
|
42
|
-
esprit = Esprit(
|
|
84
|
+
esprit = Esprit(
|
|
85
|
+
driver_path="C:/path/to/chromedriver.exe",)
|
|
43
86
|
|
|
44
87
|
# Replace with your actual ID and password
|
|
45
88
|
id = 'ID'
|
|
@@ -58,5 +101,7 @@ if absences is not None:
|
|
|
58
101
|
print(absence)
|
|
59
102
|
else:
|
|
60
103
|
print("Failed to get absences.")
|
|
104
|
+
|
|
61
105
|
```
|
|
106
|
+
|
|
62
107
|
More examples can be found in the [examples folder](examples)
|
|
@@ -11,7 +11,7 @@ with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
|
|
|
11
11
|
with open(os.path.join(here, 'requirements.txt')) as f:
|
|
12
12
|
requirements = f.read().splitlines()
|
|
13
13
|
|
|
14
|
-
VERSION = '0.3.
|
|
14
|
+
VERSION = '0.3.4'
|
|
15
15
|
DESCRIPTION = ' A Python library for interacting with data from esprit-tn.com'
|
|
16
16
|
LONG_DESCRIPTION = 'esprit-py, provides a set of tools for interacting with data from the Esprit website. It includes functionalities for scraping grades, absences, time schedules, and credits. It also provides the ability to download files and get class week schedules.'
|
|
17
17
|
|
esprit-py-0.3.2/README.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# <img src="https://esprit.tn/favicon.ico" width="28px" /> esprit-py
|
|
2
|
-
|
|
3
|
-
> [!NOTE]
|
|
4
|
-
> Please note that this library is not an official API provided by Esprit and is intended for educational and personal use only.
|
|
5
|
-
|
|
6
|
-
## Features
|
|
7
|
-
|
|
8
|
-
- Get your exact timetable pdf *not 300 pages pdf*
|
|
9
|
-
- Get your grades
|
|
10
|
-
- Get your absences
|
|
11
|
-
- Get your credits
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
pip install esprit-py
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Example
|
|
20
|
-
|
|
21
|
-
```python
|
|
22
|
-
from esprit import Esprit
|
|
23
|
-
|
|
24
|
-
# Create an Esprit object
|
|
25
|
-
esprit = Esprit()
|
|
26
|
-
|
|
27
|
-
# Replace with your actual ID and password
|
|
28
|
-
id = 'ID'
|
|
29
|
-
password = 'PASSWORD'
|
|
30
|
-
|
|
31
|
-
# Attempt to log in
|
|
32
|
-
if esprit.login(id, password):
|
|
33
|
-
print("Login successful.")
|
|
34
|
-
else:
|
|
35
|
-
print("Login failed.")
|
|
36
|
-
|
|
37
|
-
# Get absences
|
|
38
|
-
absences = esprit.get_absences()
|
|
39
|
-
if absences is not None:
|
|
40
|
-
for absence in absences:
|
|
41
|
-
print(absence)
|
|
42
|
-
else:
|
|
43
|
-
print("Failed to get absences.")
|
|
44
|
-
```
|
|
45
|
-
More examples can be found in the [examples folder](examples)
|
esprit-py-0.3.2/esprit/grade.py
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
from bs4 import BeautifulSoup
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Grade:
|
|
6
|
-
"""
|
|
7
|
-
A class used to represent a Grade.
|
|
8
|
-
|
|
9
|
-
...
|
|
10
|
-
|
|
11
|
-
Attributes
|
|
12
|
-
----------
|
|
13
|
-
url : str
|
|
14
|
-
a formatted string that represents the URL of the grade page
|
|
15
|
-
session : requests.Session
|
|
16
|
-
a Session object from the requests library
|
|
17
|
-
|
|
18
|
-
Methods
|
|
19
|
-
-------
|
|
20
|
-
get_grades():
|
|
21
|
-
Returns a list of grades for the student.
|
|
22
|
-
"""
|
|
23
|
-
|
|
24
|
-
def __init__(self, session):
|
|
25
|
-
self.url = "https://esprit-tn.com/ESPOnline/Etudiants/Resultat2021.aspx"
|
|
26
|
-
self.session = session
|
|
27
|
-
|
|
28
|
-
def get_grades(self):
|
|
29
|
-
"""
|
|
30
|
-
Returns a list of grades for the student.
|
|
31
|
-
|
|
32
|
-
Returns
|
|
33
|
-
-------
|
|
34
|
-
list
|
|
35
|
-
a list of grades, each represented as a list of strings. The first list is the headers.
|
|
36
|
-
Returns None if the page does not contain the expected text.
|
|
37
|
-
"""
|
|
38
|
-
response = self.session.get(self.url)
|
|
39
|
-
soup = BeautifulSoup(response.text, 'html.parser')
|
|
40
|
-
|
|
41
|
-
# Check if the <h1> tag with the text "Notes Des Modules" exists
|
|
42
|
-
h1_tag = soup.find('h1', text=' Notes Des Modules ')
|
|
43
|
-
if h1_tag is None:
|
|
44
|
-
print("The page does not contain the expected text.")
|
|
45
|
-
return None
|
|
46
|
-
|
|
47
|
-
table = soup.find('table', {'id': 'ContentPlaceHolder1_GridView1'})
|
|
48
|
-
rows = table.find_all('tr')
|
|
49
|
-
headers = [cell.text.strip() for cell in rows[0].find_all('th')]
|
|
50
|
-
grades = [headers] + [[cell.text.strip() for cell in row.find_all('td')]
|
|
51
|
-
for row in rows[1:]] # Skip header row
|
|
52
|
-
return grades
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|