Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import time
- url = "http://api.myip.com/"
- while True:
- try:
- response = requests.get(url)
- if response.status_code == 200:
- data = response.json()
- print(data["ip"], flush=True)
- else:
- print("Error: HTTP status code", response.status_code, flush=True)
- time.sleep(5) # Wait for 5 seconds before making the next request
- except requests.exceptions.RequestException as e:
- print("An error occurred:", str(e), flush=True)
- time.sleep(5) # Wait for 5 seconds before making the next request
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement