Creado una funcion independiente de creacion de capturas para que sea compartida entre todos aquellos servicios que las creen.
23 lines
878 B
Python
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)
|
|
|