29 lines
878 B
Python
Raw Normal View History

2025-05-08 09:49:17 +02:00
import IP2Location
from typing import Optional, Annotated
# Load database once
2025-08-09 10:28:47 +02:00
ip2loc_db: IP2Location = IP2Location.IP2Location("IP2LOCATION-LITE-DB9.BIN")
2025-05-08 09:49:17 +02:00
2025-08-09 10:28:47 +02:00
def ermWhatTheCountry(inpIpAddress: Annotated[str, "Some IP address that ya want to get country for"]) -> str:
2025-05-08 09:49:17 +02:00
try:
skibidi = ip2loc_db.get_all(inpIpAddress)
#return rec.country_long # Full country name, e.g. "Sweden"
return skibidi.country_short
except Exception as errrrrr:
return f"Error: {errrrrr}"
2025-08-09 10:28:47 +02:00
def ermWhatTheISP(inpIpAddress: Annotated[str, "Some IP address that ya want to get ISP for"]) -> str:
2025-08-08 09:46:15 +02:00
try:
skibidi = ip2loc_db.get_all(inpIpAddress)
#return rec.country_long # Full country name, e.g. "Sweden"
return skibidi.isp
except Exception as errrrrr:
return f"Error: {errrrrr}"
2025-05-08 09:49:17 +02:00
#print(ermWhatTheCountry("65.109.142.32"))