A Python-based web scraping project that collects real-time weather data for Cairo, Egypt, stores it in a SQLite database, and allows easy analysis using Pandas.
This project automatically scrapes current weather data from freemeteo.com and saves it into a local SQLite database. The collected data can later be queried using SQL or analyzed with Pandas for data science and analytics purposes.
The script simulates a browser request to avoid HTTP 403 errors and runs at timed intervals to build a historical weather dataset.
-
Scrapes real-time weather data for Cairo
-
Extracts:
- 🌡️ Temperature
- 🌬️ Wind Speed
- 💧 Humidity
- 👁️ Visibility
- 🌪️ Pressure
- ⏱️ Timestamp
-
Stores data in a SQLite database
-
Reads data using SQL queries
-
Loads data into Pandas DataFrames for analysis
- Python
- Requests
- BeautifulSoup
- SQLite3
- Pandas
- Datetime & Time
Database Name: Cairo_Weather.DB
Table: weather
| Column | Type |
|---|---|
| id | INTEGER (Primary Key) |
| temp | INTEGER |
| wind | INTEGER |
| humidity | INTEGER |
| visibility | INTEGER |
| pressure | INTEGER |
| time_now | DATETIME |
- Clone the repository
git clone https://github.com/MuhammadRuby/Cairo-Weather-Scraper.git- Install required libraries
pip install requests beautifulsoup4 pandas- Run the script
python weather_scraper.pyThe script will:
- Fetch weather data every 5 seconds (10 iterations)
- Store the data in SQLite
- Print collected values to the console
import sqlite3
import pandas as pd
conn = sqlite3.connect("Cairo_Wather.DB")
df = pd.read_sql("SELECT * FROM weather", conn)
conn.close()
print(df.head())- Website structure changes may break the scraper
- This project is for educational purposes only
- Always respect website terms of service
Great work & happy coding! 🚀