This project combines API integration, data processing, file encryption, and weather data forecasting. It fetches real-time weather data, stores the results in CSV files, and provides an option to encrypt sensitive weather information using AES encryption.
- Retrieves current weather and forecast data from the WeatherAPI.
- Retrieves both hourly and daily weather forecasts for a specified city.
- Data includes temperature, condition, wind speed, humidity, visibility, and more.
- Example functionality is provided in
api_integration.py
.
- Saves the fetched weather data to CSV files:
current_weather.csv
hourly_forecast.csv
daily_forecast.csv
- Each CSV file is systematically created using the Pandas library.
- The saving mechanism is implemented in
scraping.py
.
- Encrypts the
current_weather.csv
file using AES (Advanced Encryption Standard). - Provides options to securely encrypt and decrypt files.
- Encryption and decryption functionalities are located in
encryption.py
.
├── api_integration.py # Fetches weather data from WeatherAPI
├── scraping.py # Saves weather data and calls encryption methods
├── encryption.py # AES encryption and decryption for files
├── current_weather.csv # Sample CSV file with current weather data
├── hourly_forecast.csv # Sample hourly forecast CSV
├── daily_forecast.csv # Sample daily forecast CSV
├── current_weather_encrypted.bin # AES-encrypted binary file
-
api_integration.py
Handles API calls to fetch current weather and forecast data from WeatherAPI.- Functions:
fetch_current_weather(city_name)
: Fetches the current weather for a city.fetch_forecast(city_name, days=3)
: Retrieves an hourly and daily forecast for a city (default: 3 days).
- Functions:
-
scraping.py
Saves the weather data into CSV files, usingapi_integration.py
for weather data andencryption.py
for AES encryption.- Key Feature:
- Programmatically fetches and saves weather data for a city.
- Encrypts the
current_weather.csv
data file and generates a binary output.
- Key Feature:
-
encryption.py
Handles encryption and decryption for sensitive weather data files using AES.- Functions:
encrypt_file(input_file, output_file, key)
: Encrypts the input file and saves it to the output file.decrypt_file(input_file, output_file, key)
: Decrypts an encrypted file and restores it to its original state.
- Functions:
-
Sample Weather Data Files:
current_weather.csv
: Stores single-day weather data for the specified city.hourly_forecast.csv
: Shows hourly weather forecast data.daily_forecast.csv
: Provides a multi-day weather forecast summary.
-
current_weather_encrypted.bin
A sample AES-encrypted file demonstrating the encryption of weather data.
To run this project locally, you’ll need the following:
- Python 3.8+
- Required libraries:
requests
: For making API calls.pandas
: For handling CSV file manipulations.pycryptodome
: For AES encryption.
Install the required libraries using:
pip install requests pandas pycryptodome
The project uses WeatherAPI to fetch weather data. You need to have an API key from WeatherAPI. Place your API key in api_integration.py
:
API_KEY = "YOUR_API_KEY_HERE"
-
Ensure all dependencies are installed.
-
Replace the placeholder city name (e.g.,
Vlora
) with the desired city. -
Execute
scraping.py
to fetch, save, and encrypt weather data:python scraping.py
-
The script will:
- Save the weather data in CSV files.
- Encrypt
current_weather.csv
and save the encrypted output tocurrent_weather_encrypted.bin
.
-
To decrypt the file, use the same key that was generated during encryption:
encryption.decrypt_file(input_file, output_file, key)
- Fetch the real-time weather data for
Vlora
. - Save the results to the following CSV files:
current_weather.csv
hourly_forecast.csv
daily_forecast.csv
- Encrypt the
current_weather.csv
file and store the output incurrent_weather_encrypted.bin
.