Selam Dostlar,
Bu konuda biraz acemiyim, IP adresinden profesyonel tespitler yapabileceğim uygulama geliştirmeye çalışıyorum.
Aşağıda bir şeyler kodladım, sizin fikriniz var mı ?
IP adresinden ne kadar bilgilere ulaşabiliriz herhangi bir API bağlantısı olmadan
import socket
import requests
def ip_geolocation(ip_address):
try:
hostname = socket.gethostbyaddr(ip_address)[0]
print(f"Hostname: {hostname}")
except socket.herror:
print("Hostname not found")
try:
ip_info = socket.gethostbyname_ex(ip_address)
ips = ip_info[2]
print("IP addresses:")
for ip in ips:
print(f"- {ip}")
except socket.gaierror:
print("IP addresses not found")
try:
url = f"The trusted source for IP address data, leading IP data provider{ip_address}/json"
response = requests.get(url)
data = response.json()
country = data.get('country')
region = data.get('region')
city = data.get('city')
postal = data.get('postal')
print(f"Country: {country}")
print(f"Region: {region}")
print(f"City: {city}")
print(f"Postal Code: {postal}")
except requests.exceptions.RequestException:
print("Location data not found")
# Örnek kullanım
ip_address = "8.8.8.8" # İstediğiniz IP adresini buraya girin
ip_geolocation(ip_address)[/CODE][/ICODE]
Bu konuda biraz acemiyim, IP adresinden profesyonel tespitler yapabileceğim uygulama geliştirmeye çalışıyorum.
Aşağıda bir şeyler kodladım, sizin fikriniz var mı ?
IP adresinden ne kadar bilgilere ulaşabiliriz herhangi bir API bağlantısı olmadan
import socket
import requests
def ip_geolocation(ip_address):
try:
hostname = socket.gethostbyaddr(ip_address)[0]
print(f"Hostname: {hostname}")
except socket.herror:
print("Hostname not found")
try:
ip_info = socket.gethostbyname_ex(ip_address)
ips = ip_info[2]
print("IP addresses:")
for ip in ips:
print(f"- {ip}")
except socket.gaierror:
print("IP addresses not found")
try:
url = f"The trusted source for IP address data, leading IP data provider{ip_address}/json"
response = requests.get(url)
data = response.json()
country = data.get('country')
region = data.get('region')
city = data.get('city')
postal = data.get('postal')
print(f"Country: {country}")
print(f"Region: {region}")
print(f"City: {city}")
print(f"Postal Code: {postal}")
except requests.exceptions.RequestException:
print("Location data not found")
# Örnek kullanım
ip_address = "8.8.8.8" # İstediğiniz IP adresini buraya girin
ip_geolocation(ip_address)[/CODE][/ICODE]