A small Python web parsing example that collects school result data from a public result portal, converts the parsed HTML into a structured table, ranks students by total marks, and exports the results as CSV and Excel files.
This project is meant as a learning example for:
- Sending form requests with
requests - Parsing HTML tables with
BeautifulSoup - Cleaning scraped fields into a Python dictionary
- Creating reports with
pandas - Exporting parsed data to
.csvand.xlsx
The script:
- Generates roll numbers from a school code and roll range.
- Sends a POST request for each roll number.
- Parses student details, subject marks, total marks, grade, and percentage.
- Builds a
pandasDataFrame. - Adds rank information.
- Saves:
school_results.csvschool_results.xlsxtop_10_students.csv
- Prints a simple school report in the terminal.
.
├── main.py
├── requirements.txt
├── README.md
├── LICENSE
└── .gitignore
Generated result files are intentionally ignored by Git because they may contain personal student information.
- Python 3.10 or newer
- Internet connection
Install dependencies:
pip install -r requirements.txtOpen main.py and check the configuration values near the top:
school_code = "036DB"
start_roll = 1
end_roll = 341Then run:
python main.pyAfter the script finishes, output files will be created in the project folder.
The generated dataset can include fields such as:
- Roll number
- Student name
- Parent names
- Date of birth
- School name
- Subject marks
- Total marks
- Grade
- Percentage
- Rank
This parser is for educational purposes. Before scraping or publishing any result data:
- Respect the target website's terms of use.
- Avoid sending high-frequency requests.
- Do not upload generated CSV/XLSX files containing private student data.
- Use only data you are allowed to access and process.
The parser depends on the current HTML structure of the result website. If the website layout changes, the parsing rules in main.py may need updates.