drogon/refresher/refresher.py
2020-11-03 07:29:17 +01:00

38 lines
1,011 B
Python

import sys
sys.path.append("..")
from time import sleep
from db_layer.capturas_interface import capturas_interface
from db_layer.capturing_tasks_interface import capturing_interface
from core.config import refresher_delay
class Refresher:
def start(self):
while True:
sleep(refresher_delay)
old_ad = capturas_interface.get_old_ad()
if 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.
"""
try:
if ":-|" in html or "El anunciante lo dio de baja" in html:
return True
else:
return False
except TypeError:
return False
if __name__ == "__main__":
refresher = Refresher()
refresher.start()