diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 846e9e7..8c8c303 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,6 +4,9 @@ + + + @@ -234,6 +257,22 @@ + + + + + + + + + + + + + + + + @@ -303,7 +342,7 @@ - + @@ -584,7 +623,14 @@ @@ -600,7 +646,7 @@ - + @@ -608,11 +654,11 @@ - + - + @@ -689,7 +735,8 @@ - @@ -887,13 +934,6 @@ - - - - - - - @@ -901,13 +941,6 @@ - - - - - - - @@ -922,20 +955,6 @@ - - - - - - - - - - - - - - @@ -943,6 +962,16 @@ + + + + + + + + + + @@ -957,27 +986,55 @@ + + + + + + + + + + + + + + - - + + - + - - + + - + - - + + + + + + + + + + + + + + + + @@ -988,10 +1045,10 @@ - + - - + + diff --git a/capturer/capturer.py b/capturer/capturer.py index 04c1301..5e75bd0 100644 --- a/capturer/capturer.py +++ b/capturer/capturer.py @@ -202,7 +202,7 @@ class AdHtmlParser: posible_m2 = [tag.text for tag in soup.find('div', {'class': 'info-features'}).find_all('span')] if [posible for posible in posible_m2 if 'm²' in posible]: self.ad_fields['m2']['value'] = \ - [''.join(re.findall(r'[0-9]', posible)) for posible in posible_m2 if 'm²' in posible][0] + [''.join(re.findall(r'[0-9]+,*[0-9]*', posible)) for posible in posible_m2 if 'm²' in posible][0].replace(',', '.') self.ad_fields['m2']['found'] = True if soup.find('title') is not None: diff --git a/core/config.py b/core/config.py index cee11eb..90dd571 100644 --- a/core/config.py +++ b/core/config.py @@ -1,7 +1,7 @@ from os import environ import datetime -databases = {'dev':{'host': 'dev_drogon_db', +databases = {'dev':{'host': '185.166.215.170 ', 'user': 'drogon', 'password': 'noesfacilvivirsindrogon'}, 'tst':{'host': '46.183.114.164', @@ -14,7 +14,10 @@ databases = {'dev':{'host': 'dev_drogon_db', 'user': 'drogon', 'password': 'noesfacilvivirsindrogon'}} -current_db = environ['DROGON_ENV'] +try: + current_db = environ['DROGON_ENV'] +except KeyError: + current_db = 'dev' try: current_db_parameters = databases[current_db] diff --git a/db_layer/db_init_scripts/1_20181028dump.sql b/db_layer/db_init_scripts/1_20181028dump.sql index 1ee189d..1fc8c27 100644 --- a/db_layer/db_init_scripts/1_20181028dump.sql +++ b/db_layer/db_init_scripts/1_20181028dump.sql @@ -174,7 +174,7 @@ CREATE TABLE `capturas` ( `fecha_captura` datetime NOT NULL, `referencia` int(11) NOT NULL, `precio` int(11) NOT NULL, - `m2` int(11) DEFAULT NULL, + `m2` decimal(8,2) DEFAULT NULL, `tamano_categorico` varchar(255) CHARACTER SET utf8 DEFAULT NULL, `tipo_anuncio` int(11) NOT NULL, `calle` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL, diff --git a/tests/capturer_tests.py b/tests/capturer_tests.py index 7a5f57b..8b30763 100644 --- a/tests/capturer_tests.py +++ b/tests/capturer_tests.py @@ -2,12 +2,12 @@ import sys sys.path.append('..') from capturer.capturer import CapturingTask, Capturer - +from db_layer.capturas_interface import capturas_interface def test_CapturingTask(): parameters = {'uuid': 'testie test', - 'ad_url': 'https://www.idealista.com/inmueble/81514847', + 'ad_url': 'https://www.idealista.com/inmueble/39627481', 'fk_uuid_exploring': None, 'status': 'Pending'} @@ -15,6 +15,7 @@ def test_CapturingTask(): task.capture() print(task.get_ad_data()) + capturas_interface.insert_captura(task.get_ad_data()) def test_Capturer():