Formatting.
This commit is contained in:
parent
cd9c3b6e39
commit
a79fc533ee
11 changed files with 231 additions and 204 deletions
|
|
@ -1,15 +1,18 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
|
||||
sys.path.append("..")
|
||||
from capturer.capturer import CapturingTask, Capturer, AdHtmlParser
|
||||
from db_layer.capturas_interface import capturas_interface
|
||||
|
||||
|
||||
def test_CapturingTask():
|
||||
parameters = {'uuid': 'testie test',
|
||||
'ad_url': 'https://www.idealista.com/inmueble/28252032',
|
||||
'fk_uuid_exploring': None,
|
||||
'status': 'Pending'}
|
||||
parameters = {
|
||||
"uuid": "testie test",
|
||||
"ad_url": "https://www.idealista.com/inmueble/28252032",
|
||||
"fk_uuid_exploring": None,
|
||||
"status": "Pending",
|
||||
}
|
||||
|
||||
task = CapturingTask(parameters)
|
||||
|
||||
|
|
@ -22,6 +25,7 @@ def test_Capturer():
|
|||
capturer = Capturer()
|
||||
capturer.start()
|
||||
|
||||
|
||||
def test_AdHtmlParser():
|
||||
|
||||
html = """
|
||||
|
|
@ -225,8 +229,8 @@ var configTwoSteps = {
|
|||
parser._validate()
|
||||
|
||||
|
||||
#test_AdHtmlParser()
|
||||
# test_AdHtmlParser()
|
||||
|
||||
test_CapturingTask()
|
||||
|
||||
#test_Capturer()
|
||||
# test_Capturer()
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
from geocoder.geocoder import Geocoder, GeocodingTask, GeocodingCache
|
||||
|
||||
sys.path.append("..")
|
||||
from geocoder.geocoder import Geocoder, GeocodingTask, GeocodingCache
|
||||
|
||||
|
||||
def test_GeocodingTask():
|
||||
|
||||
good_address = 'Avinguda de la Republica Argentina 245, Barcelona'
|
||||
bad_address = 'ASdasda, 123asd'
|
||||
good_address = "Avinguda de la Republica Argentina 245, Barcelona"
|
||||
bad_address = "ASdasda, 123asd"
|
||||
|
||||
good_task = GeocodingTask(good_address)
|
||||
good_task.geocode()
|
||||
|
|
@ -20,25 +20,30 @@ def test_GeocodingTask():
|
|||
print(bad_address.is_successfull())
|
||||
print(bad_address.get_results())
|
||||
|
||||
|
||||
def test_GeocodingCache():
|
||||
|
||||
cache = GeocodingCache()
|
||||
|
||||
test_record = {'address':'Calle Don Pepito',
|
||||
'latitude': 12.1,
|
||||
'longitude': 1.12,
|
||||
'precision': 'absoluta'}
|
||||
test_record = {
|
||||
"address": "Calle Don Pepito",
|
||||
"latitude": 12.1,
|
||||
"longitude": 1.12,
|
||||
"precision": "absoluta",
|
||||
}
|
||||
|
||||
print(cache.address_in_cache(test_record['address']))
|
||||
cache.add_address(test_record['address'],
|
||||
test_record['latitude'],
|
||||
test_record['longitude'],
|
||||
test_record['precision'])
|
||||
print(cache.address_in_cache(test_record["address"]))
|
||||
cache.add_address(
|
||||
test_record["address"],
|
||||
test_record["latitude"],
|
||||
test_record["longitude"],
|
||||
test_record["precision"],
|
||||
)
|
||||
|
||||
print(cache.address_in_cache(test_record['address']))
|
||||
print(cache.get_coordinates(test_record['address']))
|
||||
print(cache.address_in_cache(test_record["address"]))
|
||||
print(cache.get_coordinates(test_record["address"]))
|
||||
|
||||
|
||||
#test_GeocodingTask()
|
||||
# test_GeocodingTask()
|
||||
|
||||
test_GeocodingCache()
|
||||
test_GeocodingCache()
|
||||
|
|
|
|||
|
|
@ -3,104 +3,125 @@ from analysis.index_batch import IndexMM
|
|||
import pandas as pd
|
||||
|
||||
sample_market = [
|
||||
{'tamano_categorico': 'coche pequeño',
|
||||
'tipo_anuncio': 1,
|
||||
'precio': 15000,
|
||||
'calle': 'B1',
|
||||
'telefono': 123,
|
||||
'latitud': 2.1,
|
||||
'longitud': 1.2},
|
||||
{'tamano_categorico': 'coche pequeño',
|
||||
'tipo_anuncio': 1,
|
||||
'precio': 20000,
|
||||
'calle': 'B2',
|
||||
'telefono': 321,
|
||||
'latitud': 2.1,
|
||||
'longitud': 1.2},
|
||||
{'tamano_categorico': 'coche grande',
|
||||
'tipo_anuncio': 1,
|
||||
'precio': 20000,
|
||||
'calle': 'B2',
|
||||
'telefono': 321,
|
||||
'latitud': 2.1,
|
||||
'longitud': 1.2},
|
||||
{'tamano_categorico': 'coche grande',
|
||||
'tipo_anuncio': 1,
|
||||
'precio': 25000,
|
||||
'calle': 'B2',
|
||||
'telefono': 123,
|
||||
'latitud': 2.1,
|
||||
'longitud': 1.2},
|
||||
{'tamano_categorico': 'coche y moto',
|
||||
'tipo_anuncio': 1,
|
||||
'precio': 22000,
|
||||
'calle': 'B1',
|
||||
'telefono': 456,
|
||||
'latitud': 2.1,
|
||||
'longitud': 1.2},
|
||||
{'tamano_categorico': 'coche y moto',
|
||||
'tipo_anuncio': 1,
|
||||
'precio': 26000,
|
||||
'calle': 'B3',
|
||||
'telefono': 789,
|
||||
'latitud': 2.1,
|
||||
'longitud': 1.2},
|
||||
{'tamano_categorico': None,
|
||||
'tipo_anuncio': 1,
|
||||
'precio': 15000,
|
||||
'calle': 'abc',
|
||||
'telefono': 456,
|
||||
'latitud': 2.1,
|
||||
'longitud': 1.2},
|
||||
{'tamano_categorico': 'moto',
|
||||
'tipo_anuncio': 1,
|
||||
'precio': 3000,
|
||||
'calle': 'B4',
|
||||
'telefono': 123,
|
||||
'latitud': 2.1,
|
||||
'longitud': 1.2},
|
||||
{'tamano_categorico': '2 coches o más',
|
||||
'tipo_anuncio': 1,
|
||||
'precio': 60000,
|
||||
'calle': 'B4',
|
||||
'telefono': 123,
|
||||
'latitud': 2.1,
|
||||
'longitud': 1.2},
|
||||
{'tamano_categorico': 'coche pequeño',
|
||||
'tipo_anuncio': 1,
|
||||
'precio': 20000,
|
||||
'calle': 'B2',
|
||||
'telefono': 321,
|
||||
'latitud': 2.1,
|
||||
'longitud': 1.2},
|
||||
{'tamano_categorico': 'coche pequeño',
|
||||
'tipo_anuncio': 2,
|
||||
'precio': 50,
|
||||
'calle': 'B4',
|
||||
'telefono': 123,
|
||||
'latitud': 2.1,
|
||||
'longitud': 1.2},
|
||||
{'tamano_categorico': 'moto',
|
||||
'tipo_anuncio': 1,
|
||||
'precio': 300000,
|
||||
'calle': 'B4',
|
||||
'telefono': 123,
|
||||
'latitud': 2.1,
|
||||
'longitud': 1.2}
|
||||
]
|
||||
date_range = {'start': '2018-01-01 00:00:00',
|
||||
'end': '2018-02-01 00:00:00'}
|
||||
{
|
||||
"tamano_categorico": "coche pequeño",
|
||||
"tipo_anuncio": 1,
|
||||
"precio": 15000,
|
||||
"calle": "B1",
|
||||
"telefono": 123,
|
||||
"latitud": 2.1,
|
||||
"longitud": 1.2,
|
||||
},
|
||||
{
|
||||
"tamano_categorico": "coche pequeño",
|
||||
"tipo_anuncio": 1,
|
||||
"precio": 20000,
|
||||
"calle": "B2",
|
||||
"telefono": 321,
|
||||
"latitud": 2.1,
|
||||
"longitud": 1.2,
|
||||
},
|
||||
{
|
||||
"tamano_categorico": "coche grande",
|
||||
"tipo_anuncio": 1,
|
||||
"precio": 20000,
|
||||
"calle": "B2",
|
||||
"telefono": 321,
|
||||
"latitud": 2.1,
|
||||
"longitud": 1.2,
|
||||
},
|
||||
{
|
||||
"tamano_categorico": "coche grande",
|
||||
"tipo_anuncio": 1,
|
||||
"precio": 25000,
|
||||
"calle": "B2",
|
||||
"telefono": 123,
|
||||
"latitud": 2.1,
|
||||
"longitud": 1.2,
|
||||
},
|
||||
{
|
||||
"tamano_categorico": "coche y moto",
|
||||
"tipo_anuncio": 1,
|
||||
"precio": 22000,
|
||||
"calle": "B1",
|
||||
"telefono": 456,
|
||||
"latitud": 2.1,
|
||||
"longitud": 1.2,
|
||||
},
|
||||
{
|
||||
"tamano_categorico": "coche y moto",
|
||||
"tipo_anuncio": 1,
|
||||
"precio": 26000,
|
||||
"calle": "B3",
|
||||
"telefono": 789,
|
||||
"latitud": 2.1,
|
||||
"longitud": 1.2,
|
||||
},
|
||||
{
|
||||
"tamano_categorico": None,
|
||||
"tipo_anuncio": 1,
|
||||
"precio": 15000,
|
||||
"calle": "abc",
|
||||
"telefono": 456,
|
||||
"latitud": 2.1,
|
||||
"longitud": 1.2,
|
||||
},
|
||||
{
|
||||
"tamano_categorico": "moto",
|
||||
"tipo_anuncio": 1,
|
||||
"precio": 3000,
|
||||
"calle": "B4",
|
||||
"telefono": 123,
|
||||
"latitud": 2.1,
|
||||
"longitud": 1.2,
|
||||
},
|
||||
{
|
||||
"tamano_categorico": "2 coches o más",
|
||||
"tipo_anuncio": 1,
|
||||
"precio": 60000,
|
||||
"calle": "B4",
|
||||
"telefono": 123,
|
||||
"latitud": 2.1,
|
||||
"longitud": 1.2,
|
||||
},
|
||||
{
|
||||
"tamano_categorico": "coche pequeño",
|
||||
"tipo_anuncio": 1,
|
||||
"precio": 20000,
|
||||
"calle": "B2",
|
||||
"telefono": 321,
|
||||
"latitud": 2.1,
|
||||
"longitud": 1.2,
|
||||
},
|
||||
{
|
||||
"tamano_categorico": "coche pequeño",
|
||||
"tipo_anuncio": 2,
|
||||
"precio": 50,
|
||||
"calle": "B4",
|
||||
"telefono": 123,
|
||||
"latitud": 2.1,
|
||||
"longitud": 1.2,
|
||||
},
|
||||
{
|
||||
"tamano_categorico": "moto",
|
||||
"tipo_anuncio": 1,
|
||||
"precio": 300000,
|
||||
"calle": "B4",
|
||||
"telefono": 123,
|
||||
"latitud": 2.1,
|
||||
"longitud": 1.2,
|
||||
},
|
||||
]
|
||||
date_range = {"start": "2018-01-01 00:00:00", "end": "2018-02-01 00:00:00"}
|
||||
|
||||
|
||||
market = Market()
|
||||
market.load_market(sample_market,
|
||||
date_range=date_range)
|
||||
market.load_market(sample_market, date_range=date_range)
|
||||
market.market.fillna(value=pd.np.nan, inplace=True)
|
||||
print(market.market.to_string())
|
||||
market.clean_market('index')
|
||||
market.clean_market("index")
|
||||
print(market.market.to_string())
|
||||
|
||||
index = IndexMM()
|
||||
index.calculate(market)
|
||||
index.get_data()
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ print(capturas_interface.old_ads_exist())
|
|||
print(capturas_interface.get_old_ad())
|
||||
|
||||
|
||||
|
||||
html_baja = """
|
||||
<!DOCTYPE html>
|
||||
|
||||
|
|
@ -256,4 +255,4 @@ var configTwoSteps = {
|
|||
"""
|
||||
|
||||
print(Refresher.dead_ad_checker(html_baja))
|
||||
print(Refresher.dead_ad_checker(html_normal))
|
||||
print(Refresher.dead_ad_checker(html_normal))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
from core.scrapping_utils import *
|
||||
|
||||
|
||||
|
||||
def UrlAttack_test(url):
|
||||
|
||||
attack = UrlAttack(url)
|
||||
|
|
@ -14,4 +13,4 @@ def UrlAttack_test(url):
|
|||
print(attack.get_text())
|
||||
|
||||
|
||||
UrlAttack_test('https://www.idealista.com/inmueble/82810718/')
|
||||
UrlAttack_test("https://www.idealista.com/inmueble/82810718/")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue