Skip to content

Instantly share code, notes, and snippets.

@NicholasLeader
Created November 22, 2023 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NicholasLeader/53e3bec382f83d9531a916af59c292cf to your computer and use it in GitHub Desktop.
Save NicholasLeader/53e3bec382f83d9531a916af59c292cf to your computer and use it in GitHub Desktop.
Return External IP via Ipify API python example
# 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