import socket
hostname = socket.gethostname()
IPAddr = socket.gethostbyname(hostname)
print("Your Computer Name is:" + hostname)
print("Your Computer IP Address is:" + IPAddr)
#How to get the IP address of a client using socket
import requests
# get your current public ip's info:
req = requests.get('https://utilities.tk/network/info')
# or specify an ip to check
req = requests.get('https://utilities.tk/network/info?ip=1.1.1.1')
print(req.status_code)
print(req.json())
import requests
# Prints public IPv4 address:
print(requests.get('https://utilities.tk/network/info').json()['ip'])
# Prints more info like location, hostname etc
print(requests.get('https://utilities.tk/network/info').json())
import socket
local_ip = socket.gethostbyname(socket.gethostname)
print(f"[+] Your Local IP is : {local_ip}")
import socket
socket.gethostbyname(socket.gethostname())
import re
f = open('C:/Users/Admin/Downloads/iplogs.txt', 'r') #Text file with many ip address
o = f.read()
ip1 = re.findall( r"d{1,3}.d{1,3}.d{1,3}.d{1,3}", o )
hosts = ip1
for host in hosts:
print(host)