diff --git a/capturer/capturer.py b/capturer/capturer.py index 8ef69b3..0a86bad 100644 --- a/capturer/capturer.py +++ b/capturer/capturer.py @@ -261,7 +261,6 @@ class AdHtmlParser: # TODO capturar datos de visitas - def _validate(self): self.invalid_fields = [] @@ -287,11 +286,9 @@ class AdHtmlParser: self.invalid_fields.append('distrito') if (self.ad_fields['telefono']['found'] - and not re.match(r"[0-9]{1,20}", self.ad_fields['telefono']['value'])): + and not re.match(r".\+?.[0-9]{1,20}", self.ad_fields['telefono']['value'])): self.invalid_fields.append('telefono') - - - + #TODO añadir + a caracteres validos def all_fields_are_valid(self): self._validate() diff --git a/tests/capturer_tests.py b/tests/capturer_tests.py index 8b30763..472aea9 100644 --- a/tests/capturer_tests.py +++ b/tests/capturer_tests.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import sys sys.path.append('..') -from capturer.capturer import CapturingTask, Capturer +from capturer.capturer import CapturingTask, Capturer, AdHtmlParser from db_layer.capturas_interface import capturas_interface @@ -22,7 +22,208 @@ def test_Capturer(): capturer = Capturer() capturer.start() +def test_AdHtmlParser(): -test_CapturingTask() + html = """ -# test_Capturer() \ No newline at end of file + + + + + + + + + + + + + Alquiler de Garaje en calle de Balmes, 138, La Dreta de l'Eixample, Barcelona

Alquiler de Garaje en calle de Balmes, 138 La Dreta de l'Eixample, Barcelona Ver mapa

30 €/mes
1 m²

Comentario del anunciante

Características básicas

  • 1 m²

¿Hay algún error en este anuncio?

Infórmanos para corregirlo y ayudar a otros usuarios.

Cuéntanos qué error has visto

¿Cuánto vale este inmueble?

Te enviamos un informe con la estimación de precio para este inmueble y con información de la zona.

Comprar estimación de precio

Ubicación

  • Calle de Balmes, 138
  • Urb. Eixample esquerra
  • Barrio La Dreta de l'Eixample
  • Distrito Eixample
  • Barcelona
  • Área de Barcelona, Barcelona

Estadísticas

+ +""" + + parser = AdHtmlParser(html) + + parser.parse() + parser._validate() + + +test_AdHtmlParser() + +#test_CapturingTask() + +#test_Capturer() \ No newline at end of file