mirror of
https://github.com/metafy-social/python-scripts.git
synced 2025-01-30 13:13:47 +00:00
Merge pull request #28 from lordvader501/ip-checker
new code for ip checking
This commit is contained in:
commit
bbe27a15d8
|
@ -1,10 +1,14 @@
|
||||||
# Public IP Address
|
# Public IP Address
|
||||||
### Find your external IP address on the internet
|
### 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.
|
It is a python code to make a request to [https://ipv4.icanhazip.com](https://ipv4.icanhazip.com), 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.
|
This response is in HTML so it also extracts only useful information from it and prints it as an output.
|
||||||
|
|
||||||
|
#### Requirements:
|
||||||
|
* Install requests module.
|
||||||
|
* run `pip install requests`
|
||||||
|
|
||||||
#### Usage
|
#### Usage
|
||||||
|
|
||||||
* Clone the repo
|
* Clone the repo
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
from urllib.request import urlopen
|
from requests import get
|
||||||
|
|
||||||
url = "http://checkip.dyndns.org"
|
ip = get('https://ipv4.icanhazip.com').text
|
||||||
|
|
||||||
print("Making request to " + url + "...")
|
print('>>> My public IP address is: ' + ip[0:-1] + ' <<<')
|
||||||
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