From f51720e5f057096f2c1b3bc54682f3f2362d26e2 Mon Sep 17 00:00:00 2001 From: Shinryin Date: Sat, 8 Apr 2023 19:04:55 -0500 Subject: [PATCH] 1.1.0 Update to a far faster, more accurate, and bug-free API. This will likely be the last update for a while to this program unless anything breaks. It is very consistent and should be used instead of 1.0.0. --- ip2time.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ip2time.py b/ip2time.py index a97d6ec..7958d91 100644 --- a/ip2time.py +++ b/ip2time.py @@ -118,16 +118,16 @@ } def get_external_ip(): - response = requests.get("https://api.ipify.org?format=json") - return response.json()['ip'] + response = requests.get("http://ip-api.com/json/") + return response.json()['query'] def get_timezone(ip): while True: try: - response = requests.get(f"https://ipapi.co/{ip}/json/", timeout=5) + response = requests.get(f"http://ip-api.com/json/{ip}", timeout=5) data = response.json() timezone = data['timezone'] - location = (data['city'], data['region'], data['country']) + location = (data['city'], data['regionName'], data['country']) return (timezone, location) except Exception as e: print(f"Error getting timezone: {e}") @@ -172,5 +172,5 @@ def main(): if __name__ == "__main__": main() - + input("Press enter to close...")