Coder Social home page Coder Social logo

ip-geolocator's Introduction

IP Geolocator

IP Geolocator is a versatile tool designed to retrieve detailed geographical information about any given IP address. Utilizing advanced IP geolocation APIs, it provides comprehensive data including country, region, city, latitude, longitude, ISP, and more. This tool is invaluable for network administrators, security analysts, marketers, and anyone needing precise IP address location information.

Features

Comprehensive Geolocation Information

  • Country Detection: Identify the country associated with the IP address.
  • Region/State: Determine the specific region or state.
  • City: Discover the city where the IP address is located.
  • Latitude and Longitude: Provide exact geographical coordinates.
  • ISP Information: Identify the Internet Service Provider (ISP).
  • Time Zone: Determine the timezone of the location.
  • Postal Code: Retrieve the postal code.
  • ASN: Autonomous System Number details.

Multi-Source Data Integration

  • API Support: Fetch data from various IP geolocation APIs for enhanced accuracy.
  • Fallback Mechanism: Ensure data retrieval even if primary sources fail.

User-Friendly Graphical Interface (GUI)

  • Input IP Address: Enter the IP address to lookup.
  • Get Geolocation: Click a button to retrieve and display detailed information.
  • Visual Feedback: Results are displayed in a user-friendly format within the GUI.

Advanced Features

  • Historical Data: Access historical geolocation data.
  • Customization: Tailor settings to suit specific needs.

Installation and Usage

Prerequisites

  • Python 3.x
  • requests library
  • Tkinter (standard Python library for GUI)

Installation Steps

  1. Clone the Repository

    git clone https://github.com/kanata-05/ip-geolocator.git
    cd ip-geolocator
  2. Install Required Libraries

    Ensure you have the requests library installed:

    pip install requests

Running the Application

  1. Launch the GUI

    Run the script to open the graphical user interface (GUI):

    python ip_geolocator.py
  2. Using the GUI

    • Enter IP Address: Input the IP address you want to geolocate.
    • Get Geolocation: Click the "Get Geolocation" button to fetch and display detailed information about the IP address.
  3. Customization

    • Extend the functionality by integrating additional geolocation APIs.
    • Enhance the GUI with more features such as map visualization or bulk IP lookup capabilities.

Example

Here’s a simplified version of the GUI script:

import tkinter as tk
import requests

def get_geolocation():
    ip_address = ip_entry.get()
    url = f"https://ipwho.is/{ip_address}"
    response = requests.get(url)
    data = response.json()
    
    if 'error' in data:
        result_text.delete(1.0, tk.END)
        result_text.insert(tk.END, f"Error: {data['error']}")
    else:
        result_text.delete(1.0, tk.END)
        result_text.insert(tk.END, f"IP: {data.get('ip', 'N/A')}\n")
        result_text.insert(tk.END, f"Type: {data.get('type', 'N/A')}\n")
        result_text.insert(tk.END, f"Continent: {data.get('continent', 'N/A')}\n")
        result_text.insert(tk.END, f"Country: {data.get('country', 'N/A')}\n")
        result_text.insert(tk.END, f"Region: {data.get('region', 'N/A')}\n")
        result_text.insert(tk.END, f"City: {data.get('city', 'N/A')}\n")
        result_text.insert(tk.END, f"Latitude: {data.get('latitude', 'N/A')}\n")
        result_text.insert(tk.END, f"Longitude: {data.get('longitude', 'N/A')}\n")
        result_text.insert(tk.END, f"Postal Code: {data.get('postal', 'N/A')}\n")
        result_text.insert(tk.END, f"Calling Code: {data.get('calling_code', 'N/A')}\n")
        result_text.insert(tk.END, f"Capital: {data.get('capital', 'N/A')}\n")
        result_text.insert(tk.END, f"ASN: {data['connection'].get('asn', 'N/A')}\n")
        result_text.insert(tk.END, f"Organization: {data['connection'].get('org', 'N/A')}\n")
        result_text.insert(tk.END, f"ISP: {data['connection'].get('isp', 'N/A')}\n")
        result_text.insert(tk.END, f"Domain: {data['connection'].get('domain', 'N/A')}\n")
        result_text.insert(tk.END, f"Timezone: {data['timezone'].get('id', 'N/A')}\n")
        result_text.insert(tk.END, f"Timezone Abbreviation: {data['timezone'].get('abbr', 'N/A')}\n")
        result_text.insert(tk.END, f"Current Time: {data['timezone'].get('current_time', 'N/A')}\n")

# Create main window
root = tk.Tk()
root.title("IP Geolocator")
root.configure(bg='#202124')  # Dark theme background color

# IP address entry
ip_label = tk.Label(root, text="Enter IP Address:", bg='#202124', fg='white')
ip_label.pack()
ip_entry = tk.Entry(root)
ip_entry.pack(pady=3)

# Button to get geolocation
get_location_button = tk.Button(root, text="Get Geolocation", command=get_geolocation, bg='#37474f', fg='white')
get_location_button.pack()

# Display results
result_text = tk.Text(root, height=20, width=60, bg='#2a2d2e', fg='white')
result_text.pack()

root.mainloop()

Explanation

  • get_geolocation(): Fetches geolocation data from the ipwho.is API and displays it in the text area.
  • GUI Elements: Includes an input field for IP address, a button to trigger geolocation, and a text area to display results.

Contributing

Contributions are welcome! For suggestions, improvements, or bug fixes, please open an issue or submit a pull request following our contributing guidelines.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

If you have any questions or need further assistance, feel free to contact us at [email protected] or open an issue on this repository.


ip-geolocator's People

Contributors

kanata-05 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.