import requests
def get_public_ip( ) :
"""
Retrieves the public IP address using an external API.
"""
try :
response = requests.get ( 'https://a...content-available-to-author-only...y.org' )
response.raise_for_status ( ) # Raise an exception for bad status codes
return response.text
except requests.exceptions .RequestException as e:
print ( f"Error getting public IP: {e}" )
return None
if __name__ == "__main__" :
public_ip = get_public_ip( )
if public_ip:
print ( f"Your public IP address is: {public_ip}" )
aW1wb3J0IHJlcXVlc3RzCgpkZWYgZ2V0X3B1YmxpY19pcCgpOgogICAgIiIiCiAgICBSZXRyaWV2ZXMgdGhlIHB1YmxpYyBJUCBhZGRyZXNzIHVzaW5nIGFuIGV4dGVybmFsIEFQSS4KICAgICIiIgogICAgdHJ5OgogICAgICAgIHJlc3BvbnNlID0gcmVxdWVzdHMuZ2V0KCdodHRwczovL2EuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLnkub3JnJykKICAgICAgICByZXNwb25zZS5yYWlzZV9mb3Jfc3RhdHVzKCkgICMgUmFpc2UgYW4gZXhjZXB0aW9uIGZvciBiYWQgc3RhdHVzIGNvZGVzCiAgICAgICAgcmV0dXJuIHJlc3BvbnNlLnRleHQKICAgIGV4Y2VwdCByZXF1ZXN0cy5leGNlcHRpb25zLlJlcXVlc3RFeGNlcHRpb24gYXMgZToKICAgICAgICBwcmludChmIkVycm9yIGdldHRpbmcgcHVibGljIElQOiB7ZX0iKQogICAgICAgIHJldHVybiBOb25lCgppZiBfX25hbWVfXyA9PSAiX19tYWluX18iOgogICAgcHVibGljX2lwID0gZ2V0X3B1YmxpY19pcCgpCiAgICBpZiBwdWJsaWNfaXA6CiAgICAgICAgcHJpbnQoZiJZb3VyIHB1YmxpYyBJUCBhZGRyZXNzIGlzOiB7cHVibGljX2lwfSIp