import logging from time import sleep from core.config import refresher_delay from db_layer.capturas_interface import capturas_interface from db_layer.capturing_tasks_interface import capturing_interface class Refresher: @staticmethod def start() -> None: """ Execute main flow. :return: None """ while True: sleep(refresher_delay) logging.info("Checking for ads that need to be refreshed...") old_ad = capturas_interface.get_old_ad() if old_ad: logging.info("Found an old ad.") capturing_interface.create_capturing_task(str(old_ad["referencia"])) @staticmethod def dead_ad_checker(html): """ Comprueba si el html es de un anuncio dado de baja. :param html: HTML del anuncio en string. :return: True si esta dado de baja, False si no. """ if "anunciante" in html and "baja" in html: return True else: return False if __name__ == "__main__": refresher = Refresher() refresher.start()