A robust web scraper and API wrapper for TIU student system
Project description
TIUPY
A Python library for interacting with Tishk International University's student portal. It provides features such as user authentication, profile information retrieval, and course data extraction.
Features
- Login using username and password or an existing session SID.
- Retrieve user profile information.
- Fetch and parse course data.
Installation
To use this library, clone or download the repository. Or install the required using pip:
pip install tiupy
Usage Examples
1. Login and Fetch Profile Information
from tiupy import Tiu
# Initialize the client
tiu_client = Tiu()
try:
# Login with username and password
tiu_client.login("your_username", "your_password")
# Get profile information
profile = tiu_client.profile
print(f"Student Name: {profile.name}")
print(f"GPA: {profile.gpa}")
finally:
# Logout from the session
tiu_client.logout()
2. Login with Session SID
from tiupy import Tiu
tiu_client = Tiu()
try:
# Login with an existing SID
tiu_client.sid_login("your_existing_sid")
# Get profile information
print("Logged in with SID successfully.")
finally:
tiu_client.logout()
3. Fetch Course Data
from tiupy import Tiu
tiu_client = Tiu()
try:
# Login first
tiu_client.login("your_username", "your_password")
# Get course data
courses = tiu_client.get_courses_data()
# Print as JSON
print("Courses JSON:\n", courses.to_json())
finally:
tiu_client.logout()
4. Profile Data Attributes
After login, access the profile object for user information:
profile = tiu_client.profile
print("Name:", profile.name)
print("Email:", profile.email)
print("Department:", profile.department)
print("Mobile:", profile.mobile)
5. Course Data Attributes
Access the list of courses using the courses object:
for course in courses.courses:
print(f"{course.course_code} - {course.course_name}: {course.grade}")
Error Handling
The library raises exceptions when requests fail. Always handle potential errors:
from tiupy import Tiu
try:
tiu_client = Tiu()
tiu_client.login("wrong_user", "wrong_password")
except Exception as e:
print(f"An error occurred: {e}")
Example Scripts
1. Login Example (example_login.py)
from tiupy import Tiu
def main():
tiu_client = Tiu()
try:
tiu_client.login("your_username", "your_password")
profile = tiu_client.profile
print("Login successful.")
print("Student Name:", profile.name)
except Exception as e:
print("Error:", e)
finally:
tiu_client.logout()
if __name__ == "__main__":
main()
2. Fetch Course Data Example (example_courses.py)
from tiupy import Tiu
def main():
tiu_client = Tiu()
try:
tiu_client.login("your_username", "your_password")
courses = tiu_client.get_courses_data()
print("Courses Data:")
for course in courses.courses:
print(f"{course.course_code} - {course.course_name}: {course.grade}")
except Exception as e:
print("Error:", e)
finally:
tiu_client.logout()
if __name__ == "__main__":
main()
Contributing
Pull requests are welcome. For significant changes, please open an issue first to discuss your ideas.
License
This project is licensed under the MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tiupy-1.1.1.tar.gz.
File metadata
- Download URL: tiupy-1.1.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
450ff0e4c880d1cc98b60bf445846fba8725db0ded3d4ae187bd0a13c9bbde29
|
|
| MD5 |
1a2a46ab132640cca9705b696cb0f81c
|
|
| BLAKE2b-256 |
d1e9f783ab53dfeb5b933d01bfc402bd70a6fa88d953fec4801595dd8675d27e
|
File details
Details for the file tiupy-1.1.1-py3-none-any.whl.
File metadata
- Download URL: tiupy-1.1.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78b0b7474535224d84fd3341ce143c10e3f28b23b2e85ea2adee3eb5a39c4ef0
|
|
| MD5 |
057b3607f4252d24f3ca2bfc3fcce7fa
|
|
| BLAKE2b-256 |
62e4912f918a9957ecde45b7badcc1482404c64c22b85599df3d28be8a73c1a4
|