A module to get the the current Day, Date, Time and Temperature
Project description
WeatherNow
WeatherNow is a Python module that retrieves the current weather details for your location. It uses the OpenWeatherMap API to fetch weather data and geocoder to determine your current location based on your IP address.
Features
- Get current temperature, humidity, wind speed, and cloudiness
- Check if it is raining or snowing
- Display the current date, time, and day of the week
Installation
To use this module, you need to install the required dependencies:
pip install requests geocoder
Usage
Get an API Key from OpenWeatherMap
Sign up at OpenWeatherMap to get your free API key.
Update the API Key in the Script
Replace the placeholder API key in the script with your actual API key:
python
api_key = "your_actual_api_key_here"
Run the Script
Execute the script to get the current weather details:
bash
python whatnow.py
Example Output
markdown
City: Your City Date: 2023-05-26 Time: 14:23:45 Day: Friday Temperature: 25.0°C Humidity: 60% Wind Speed: 5.0 m/s It's Clear
Functions
get_weather_details(city_name, api_key)
Fetches weather details for the specified city using the OpenWeatherMap API.
Parameters:
city_name (str): The name of the city to fetch weather details for.
api_key (str): Your OpenWeatherMap API key.
Returns:
A dictionary with weather details such as temperature, humidity, wind speed, cloudiness, and whether it is raining or snowing.
get_location()
Determines the current location based on the IP address.
Returns:
A geocoder location object.
extract_city(location)
Extracts the city name from a geocoder location object.
Parameters:
location (geocoder object): The location object to extract the city from.
Returns:
The name of the city (str).
get_current_datetime()
Gets the current date, time, and day of the week.
Returns:
A tuple containing the current date (str), time (str), and day (str).
main()
Main function that orchestrates the retrieval and display of weather details. License
This project is licensed under the MIT License. See the LICENSE file for details. Contributing
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes. Author
Deepak Kumar Upadhayay - dku3132@gmail.com Acknowledgments
OpenWeatherMap for providing the weather API.
Geocoder for providing the location API.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file whatnow-0.1.1.tar.gz.
File metadata
- Download URL: whatnow-0.1.1.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/7.1.0 keyring/24.3.1 pkginfo/1.10.0 readme-renderer/34.0 requests-toolbelt/1.0.0 requests/2.31.0 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef96226d97cfbd583359f402b38239142629e0cd02cdf808f811a424cc0b7b90
|
|
| MD5 |
02bdf20647457c5b9156298e5e7f75fa
|
|
| BLAKE2b-256 |
f8c78a4904b50ac59cc1c7978ebaad4507d947dcf41e06b6c17078e81ef804cf
|
File details
Details for the file whatnow-0.1.1-py3-none-any.whl.
File metadata
- Download URL: whatnow-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/7.1.0 keyring/24.3.1 pkginfo/1.10.0 readme-renderer/34.0 requests-toolbelt/1.0.0 requests/2.31.0 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2501618dfd1a7cd235e5651cc41afc8c0e6dba6046862256b983035f55d25a25
|
|
| MD5 |
753984e6b0eb817b183ca81239a76fcc
|
|
| BLAKE2b-256 |
e1315925156f3353487e83c64feae3e2485218aa5deec426b060a84bc971dd92
|