This Python script scrapes academic staff information from the Faculty of Science, University of Kelaniya's website, specifically the staff details page. The script retrieves each staff member's name, position, room number, phone, fax, email, and specialization (if available) and exports the information into a CSV file.
Make sure you have the following Python packages installed before running the script:
requests
: For sending HTTP requests to fetch the webpage.beautifulsoup4
: For parsing the HTML content of the webpage.csv
: For writing the extracted data to a CSV file.
You can install the required packages using pip
:
- Extract Data from URL: The script sends a request to the webpage containing the academic staff details.
- Parse HTML: It uses BeautifulSoup to parse the HTML and identify the relevant sections for staff data.
- Retrieve Staff Information: For each academic staff member, the script extracts:
- Name
- Position
- Room number
- Phone number
- Fax
- Specialization (scraped from a link if available)
- CSV Output: The data is written to a CSV file named
academic_staff.csv
.
-
Name | Position | Room | Phone | Fax | Specialization | |
---|---|---|---|---|---|---|
Prof.Janaka Wijanayake | Professorr | Room 201 | 011-2233445 | 011-2233446 | janaka@stu.kln.ac.lk | Computer Science |
Dr. Thilini Mahanama | Senior Lecture | Room 202 | 011-1234567 | Not available | thilinie@uni.lk | Physics |
- Clone or download the repository containing this script.
- Make sure you have Python installed on your system.
- Install the required Python libraries using the following command:
pip install requests beautifulsoup4