mirror of
https://github.com/metafy-social/python-scripts.git
synced 2025-01-30 21:23:46 +00:00
add: Get your public ip
This commit is contained in:
parent
8d41da5c7f
commit
b54f7f6d3b
13
scripts/Public_IP_Address/README.md
Normal file
13
scripts/Public_IP_Address/README.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Public IP Address
|
||||
### Find your external IP address on the internet
|
||||
|
||||
It is a python code to make a request to [http://checkip.dyndns.org](http://checkip.dyndns.org), which in turn send a response back with your External IP address.
|
||||
|
||||
This response is in HTML so it also extracts only useful information from it and prints it as an output.
|
||||
|
||||
#### Usage
|
||||
|
||||
* Clone the repo
|
||||
* open the `Public IP Address` folder
|
||||
* run `python my_public_ip.py`
|
||||
* You just recieved your public IP.
|
13
scripts/Public_IP_Address/my_public_ip.py
Normal file
13
scripts/Public_IP_Address/my_public_ip.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
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)
|
Loading…
Reference in New Issue
Block a user