Created
November 22, 2023 17:18
-
-
Save NicholasLeader/53e3bec382f83d9531a916af59c292cf to your computer and use it in GitHub Desktop.
Return External IP via Ipify API python example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# returns your current public / external IP via querying API | |
# Adapted from code ipify code samples: https://www.ipify.org/ | |
# May need to install 'requests' manully via PIP etc, as 'requests' isn't install by default with python | |
# console clear method - avoids another import https://stackoverflow.com/questions/72105595/clearing-console-in-python | |
import requests | |
ip = requests.get('https://api.ipify.org').text | |
# clearing the console output | |
print("\033c", end='') | |
print('My public IP address is: {}'.format(ip)) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment