alexleotz / necta-results-scraper
This package provides a PHP script that allows you to scrape students' results from the National Examinations Council of Tanzania (NECTA) website.
Requires
- php: >=7.0.0
- symfony/browser-kit: ^6.2
- symfony/css-selector: ^6.2
- symfony/http-client: ^6.2
This package is auto-updated.
Last update: 2024-11-09 04:31:48 UTC
README
This package provides a PHP script that allows you to scrape students' results from the National Examinations Council of Tanzania (NECTA) website.
Installation
You can install this package using Composer:
composer require alexleotz/necta-results-scraper
Usage
To use this package, simply call the static result method of the NectaResultScraper class with the student form four index number string as the argument: Assuming you have a PHP file named index.php in your parent directory, simply replicate the code provided below:
<?php require_once('vendor/autoload.php'); use NectaResultScraper\NectaResultScraper; // Pass the index number string and the level as the arguments. $result = NectaResultScraper::results('S1187/0142/2022', 'csee'); // or $result = NectaResultScraper::results('S0310/0501/2023', 'acsee'); // or simply $result = NectaResultScraper::results('S1187/0142/2022'); // level is 'csee' by default // Output the result. echo json_encode($result);
Then run:
php index.php
Output
The output is student's result when converted to JSON
"gender": "F",
"division": "IV",
"points": "31",
"subjects": ["CIV", "HIST", "GEO", "KIISLAMU", "KISW", "ENGL", "BIO", "MATH"],
"subjects_grades": {
"CIV": "F",
"HIST": "D",
"GEO": "F",
"KIISLAMU": "F",
"KISW": "C",
"ENGL": "F",
"BIO": "D",
"MATH": "F"
},
"source": "https://onlinesys.necta.go.tz/results/2022/csee/results/s0596.htm"
}
Validation
The supported examination formats are slash-separated and comma-separated formats, e.g., S1187/0142/2022 or S1187.0142.2022. The package handles validation for you.
Supported years
Currently, we support all years from 2003 up to now.
Error
If the student is not found, 404 status code will be returned. For any other error, a code of 500 will be returned.
If, for any reason, you encounter the following error:
Could not find a version of the package alexleotz/necta-results-scraper matching your minimum-stability (stable). Require it with an explicit version constraint allowing its desired stability.
Create a new composer file (if none exists) and add the following line:
"minimum-stability": "stable"
Then, install this package again.
Inspiration
This package was inspired by NECTA-API Python package created by vincent laizer
Contributing
If you’d like to contribute to this project, please fork the repository and use a feature branch. Pull requests are welcome or call 0748333586 for personal support and chat!
License
This package is released under the MIT license. See LICENSE for details.