Answers for "find someones ip with python"

1

get ip python

import socket    
host = socket.getfqdn()    
addr = socket.gethostbyname(host)
print(f"Your ip is {addr}")
# On Linux, it may give you the localhost address
Posted by: Guest on November-18-2020
0

python get city name from IP

import re
import json
from urllib2 import urlopen

url = 'http://ipinfo.io/json'
response = urlopen(url)
data = json.load(response)

IP=data['ip']
org=data['org']
city = data['city']
country=data['country']
region=data['region']

print 'Your IP detailn '
print 'IP : {4} nRegion : {1} nCountry : {2} nCity : {3} nOrg : {0}'.format(org,region,country,city,IP)
Posted by: Guest on January-20-2021

Python Answers by Framework

Browse Popular Code Answers by Language