-1
Good night I’m trying to make a program that tests if the internet is working and if not returns the time that will be stored in a file so I can complain to the internet operator. Since whenever I start this program the return is always the same
from conexao import Programa
from datetime import datetime
import time
url = 'https://www.facebook.com/'
hora = Programa.hora()
conexao = Programa.conectar(url, hora)
while True:
print(conexao)
conexao
import requests
import time
from datetime import datetime
class Programa():
def conectar(url, hora):
while True:
try:
requests.get(url, timeout=5)
time.sleep(5)
return 1, hora
except :
requests.get('http://10.0.0.1/index.asp', timeout=5)
return 2, hora
else:
return 3, hora
def desconto(valor_minuto, hora):
desconto = (int(hora) - int(hora) / 60) - valor_minuto
return desconto
def hora():
hora = datetime.now().hour
minuto = datetime.now().minute
segundo = datetime.now().second
hora_caiu = (f'{hora}:{minuto}:{segundo}')
return hora_caiu