python-scripts/scripts/Public_IP_Address/my_public_ip.py

13 lines
313 B
Python
Raw Normal View History

2022-09-16 17:59:42 +00:00
from urllib.request import urlopen
url = "http://checkip.dyndns.org"
print("Making request to " + url + "...")
request = urlopen(url)
print("Reading the response...")
response = request.read()
print("Extracting your IP info...")
ip = ">>> " + response.decode("utf-8").split("body")[1][1:-2] + " <<<"
print(ip)