A tool for fetching location, weather, and map link based on IP address.
Project description
locaspy
locaspy is a Python package to fetch and display IP location information, weather details, ISP information, and more using ipinfo.io
and OpenWeatherMap API.
Installation
You can install locaspy
via pip:
pip install locaspy
Usage
import locaspy
# Get the user's IP address
ip_address = locaspy.get_ip()
# Get all information based on the IP address
info = locaspy.get_data(ip_address)
# Print all information
print("IP Address:", info["ip_address"])
print("Location:")
print(f" City: {info['city']}")
print(f" Region: {info['region']}")
print(f" Country: {info['country']}")
print(f" Country Code: {info['country_code']}")
print(f" ISP: {info['isp']}")
print(f" Languages: {info['languages']}")
print(f" Postal Code: {info['postal_code']}")
print(f" Latitude: {info['latitude']}")
print(f" Longitude: {info['longitude']}")
print(f" Open URL: {info['url']}")
print(f" Currency: {info['currency']}")
print(f" Temperature: {info['temperature']}°C")
print(f" Weather: {info['weather']}")
Fetching IP Address
import locaspy
# Get the user's IP address
ip_address = locaspy.get_ip()
print("Your IP Address:", ip_address)
Fetching Information
You can fetch various types of information based on an IP address:
Fetch Weather Information
import locaspy
ip_address = input("Enter your IP: ")
weather_info = locaspy.get_data(ip_address, "weather")
print("Weather Information:", weather_info)
Fetch Location Details
import locaspy
ip_address = input("Enter your IP: ")
location_info = locaspy.get_data(ip_address, "location")
print("Location Details:\n", location_info)
Fetch ISP Information
import locaspy
ip_address = input("Enter your IP: ")
isp_info = locaspy.get_data(ip_address, "isp")
print("ISP Information:", isp_info)
Available Information
-
The
get_data
function returns a dictionary with the following keys: -
ip_address
: IP address of the user -
city
: City name -
region
: Region or state -
country
: Country name -
country_code
: Country code -
isp
: Internet Service Provider -
languages
: Languages spoken -
postal_code
: Postal code -
latitude
: Latitude coordinate -
longitude
: Longitude coordinate -
url
: URL link to OpenStreetMap -
currency
: Currency used -
temperature
: Temperature in Celsius -
weather
: Weather condition
Example Output
- Here's an example of the output structure:
{
"ip_address": "192.168.1.1",
"city": "City",
"region": "Region",
"country": "Country",
"country_code": "CC",
"isp": "Internet Provider",
"languages": "English",
"postal_code": "12345",
"latitude": "40.7128",
"longitude": "-74.0060",
"url": "https://www.openstreetmap.org/?mlat=40.7128&mlon=-74.0060#map=15/40.7128/-74.0060",
"currency": "USD",
"temperature": "25°C",
"weather": "Sunny"
}
Thanks
Thank you for using locaspy! We appreciate your interest in our tool and hope it meets your needs.
Additional Information
For any issues, suggestions, or contributions, please visit our GitHub repository
We welcome and encourage contributions from the community. Whether it's reporting a bug, suggesting a feature, or improving the documentation, your feedback is valuable and helps us improve the project.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
We would like to acknowledge the following libraries and resources that made this project possible:
Thank you again for your support!
Project details
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
File details
Details for the file locaspy-1.0.4.tar.gz
.
File metadata
- Download URL: locaspy-1.0.4.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a002898fe2fec331420f6d88ee50b0d20202cd178f8f764ed47679d2139d9b75 |
|
MD5 | aff1a9518aab4731cf178b4a49b58857 |
|
BLAKE2b-256 | 7141b4ed7f219892275e0c54c3d3f3605abed4885c86ee2a6a1b81fe8b14b5be |
File details
Details for the file locaspy-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: locaspy-1.0.4-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14c7a71da769a8230d15e3c558f7e711e994805203a9bb383c6fe2bae34b2863 |
|
MD5 | e4f252210f8faaae9b6198b0e2029378 |
|
BLAKE2b-256 | e0811cf84ff81f46313af471e8ff2757bfb9c05e140bc3bf8afdd760dea9d0eb |