import requests
from bs4 import BeautifulSoup
import pandas as pd
import time
BASE_URL = "https://ae-online-courses-academy.com/result/azharia_results"
def extract_student_data(html_content):
soup = BeautifulSoup(html_content, 'html.parser')
# Check if result section exists
result_section = soup.find(id="result-section")
if not result_section:
return None
# Extract student name
student_name_span = result_section.select_one(".student-info span")
student_name = student_name_span.text.strip() if student_name_span else None
# Extract department
student_dept_span = result_section.select_one(".student-dept span")
student_dept = student_dept_span.text.strip() if student_dept_span else None
# Extract table data
table = result_section.find("table", id="result-table")
if not table:
return None
data = {
""االسم: student_name,
""القسم: student_dept
}
rows = table.find_all("tr")
for row in rows:
cols = row.find_all("td")
if len(cols) >= 2:
key = cols[0].text.strip()
val = cols[1].text.strip()
data[key] = val
return data
def main():
all_results = []
start_seat = 1000
end_seat = 1050 # Change to your max range
for seat_num in range(start_seat, end_seat + 1):
seat_str = str(seat_num)
print(f"Fetching data for seat number: {seat_str}")
payload = {
"seat_number": seat_str,
"view_mode": "azharia"
}
try:
response = requests.post(BASE_URL, data=payload)
if response.status_code == 200:
student_data = extract_student_data(response.text_