drogon/capturer/capturer.py
pablomartincalvo 1f372b85b6 Refactorizado Explorer para que el Explorer, y no el exploring_task, se encargue de postear las tareas de captura.
Creado una funcion independiente de creacion de capturas para que sea compartida entre todos aquellos servicios que las creen.
2018-09-21 18:19:33 +02:00

23 lines
878 B
Python

import uuid
ads_root = 'https://www.idealista.com/inmueble/'
def create_capturing_task(referencia, db_wrapper, uuid_exploring=None):
query_parameters = {'url': ads_root + referencia,
'uuid': str(uuid.uuid4()),
'status': 'Pending'}
if uuid_exploring is None:
query_statement = """INSERT INTO capturing_tasks_logs
(uuid, write_time, status, url)
VALUES (%(uuid)s, NOW(), %(status)s, url)"""
else:
query_statement = """INSERT INTO capturing_tasks_logs
(uuid, write_time, status, url, fk_uuid_exploring)
VALUES (%(uuid)s, NOW(), %(status)s, url, %(uuid_exploring))s"""
query_parameters['uuid_exploring'] = uuid_exploring
db_wrapper.query(query_statement, query_parameters)