Algorithm
Algorithm
GROUP No: 23
DHANISH AHAMMED MV (MS21218)
DILSHA NAHAN (MS21053)
9. Check if the faculty member's information already exists in the 'faculty' table:
Execute a SQL query to find a matching record.
10. Update or insert faculty information into the 'faculty' table:
If the record already exists, update it with the new designation, qualification, and research
interests.
If the record doesn't exist, insert a new record with the extracted information.
11. Commit the changes to the database after processing each faculty member.
12. Retrieve all faculty data from the 'faculty' table using a SQL SELECT query.
13. Display the faculty data as an SQLite table:
Iterate through the fetched data and print each row.
14. Close the connection to the SQLite database to save the data and release resources.
3.Name of the institute: Indian Institute of Technology Palakkad.
URL: https://iitpkd.ac.in/faculty
Algorithm of the code:
1. Import Necessary Libraries:
Import requests
From bs4 import BeautifulSoup
import sqlite3
2. Initialize SQLite Database:
Connect to an existing 'faculty_data_new.db' database or create a new one if it
doesn't exist.
Create a cursor for executing SQL commands.
4.Name of the institute: Indian Institute of Science Education and Research Trivandrum.
URL: https://www.iisertvm.ac.in/faculty
Algorithm:
1. Import Necessary Libraries:
requests
BeautifulSoup from bs4
sqlite3
2. Initialize SQLite Database:
Connect to an existing 'faculty_data.db' database or create a new one if it doesn't exist.
Create a cursor for executing SQL commands.
3. Drop Existing 'faculty' Table:
Check if the 'faculty' table exists and drop it if it does.
4. Create a New 'faculty' Table:
Define the structure of the 'faculty' table in the database with the following columns: 'id'
(INTEGER PRIMARY KEY AUTOINCREMENT), 'name' (TEXT), 'designation' (TEXT), and 'research_interest'
(TEXT).
5. Commit Table Creation:
Ensure that the new 'faculty' table is created and committed to the database.
6. HTTP Request and Parsing:
Make an HTTP GET request to the IISER Thiruvananthapuram faculty directory URL.
Parse the HTML content of the webpage using BeautifulSoup.
7. Extract Faculty Information:
Find all HTML elements with the class "faculty_inner_wrapper" in the HTML, representing
faculty members.
8. Iterate through the faculty items and extract the following information for each faculty member:
Name
Designation
Research interests
9. Check for Existing Faculty Record:
Check if the faculty member's information already exists in the 'faculty' table by executing
a SQL query to find a matching record.
10. Update or Insert Faculty Information:
If the faculty member's record already exists in the table, update it with the new
designation and research interests.
If the faculty member's record doesn't exist in the table, insert a new record with the
extracted information.
11. Commit Database Changes:
Ensure that the database is committed after processing each faculty member to save the
changes.
12. Retrieve Faculty Data:
Execute a SQL SELECT query to retrieve all faculty data from the 'faculty' table.
13. Display Faculty Data:
Iterate through the fetched data and print each faculty member's information as an SQLite
table.
14. Close the Database Connection:
Close the connection to the SQLite database to save the data and release resources.