diff --git a/modules/pap/pages.py b/modules/pap/pages.py index daee4c9829d8a64ea91c9b191390929ff18fddd4..5568f3954a5f2f5357699270fdd90b68195ee2fd 100644 --- a/modules/pap/pages.py +++ b/modules/pap/pages.py @@ -62,13 +62,13 @@ def condition(self): if self.env['query_type'] == POSTS_TYPES.RENT: isNotFurnishedOk = 'meublé' not in title.lower() return ( - Regexp(Link('./div/a[@class="item-title"]'), '/annonces/(.*)', default=None)(self) and + Regexp(Link('./div/a[has-class("item-title")]'), '/annonces/(.*)', default=None)(self) and isNotFurnishedOk ) def parse(self, el): rooms_bedrooms_area = el.xpath( - './/div[@class="clearfix"]/ul[has-class("item-tags")]/li' + './div/a[has-class("item-title")]/ul[has-class("item-tags")]/li' ) self.env['rooms'] = NotLoaded self.env['bedrooms'] = NotLoaded @@ -78,10 +78,10 @@ def parse(self, el): name = CleanText('.')(item) if 'chambre' in name.lower(): name = 'bedrooms' - value = CleanDecimal('./strong')(item) + value = CleanDecimal('.')(item) elif 'pièce' in name.lower(): name = 'rooms' - value = CleanDecimal('./strong')(item) + value = CleanDecimal('.')(item) else: name = 'area' value = CleanDecimal( @@ -94,7 +94,7 @@ def parse(self, el): )(item) self.env[name] = value - obj_id = Regexp(Link('./div/a[@class="item-title"]'), '/annonces/(.*)') + obj_id = Regexp(Link('./div/a[has-class("item-title")]'), '/annonces/(.*)') obj_type = Env('query_type') obj_advert_type = ADVERT_TYPES.PERSONAL @@ -112,24 +112,15 @@ def obj_house_type(self): else: return HOUSE_TYPES.OTHER - obj_title = CleanText('./div/a[@class="item-title"]') + obj_title = CleanText('./div/a[has-class("item-title")]') obj_area = Env('area') - obj_cost = CleanDecimal(CleanText('./div/a[@class="item-title"]/span[@class="item-price"]'), + obj_cost = CleanDecimal(CleanText('./div/a[has-class("item-title")]/span[@class="item-price"]'), replace_dots=True, default=Decimal(0)) obj_currency = Currency( './div/a[@class="item-title"]/span[@class="item-price"]' ) obj_utilities = UTILITIES.UNKNOWN - def obj_date(self): - date = CleanText( - './div/p[@class="item-date"]' - )(self).split(" / ") - if len(date) > 1: - return parse_french_date(date[1].strip()) - else: - return NotLoaded - obj_station = CleanText('./div/p[@class="item-transports"]', default=NotLoaded) def obj_location(self): diff --git a/modules/pap/test.py b/modules/pap/test.py index 9dec085b99e66e5b9e20005d89f535e94c671b0a..3c0e954ccc9496fa5913cef961b12caaef77da22 100644 --- a/modules/pap/test.py +++ b/modules/pap/test.py @@ -27,13 +27,11 @@ class PapTest(BackendTest, HousingTest): FIELDS_ALL_HOUSINGS_LIST = [ "id", "type", "advert_type", "house_type", "url", "title", "area", - "cost", "currency", "utilities", "date", "location", "text" + "cost", "currency", "utilities", "location", "text" ] FIELDS_ANY_HOUSINGS_LIST = [ "photos", "station", - "rooms", - "bedrooms" ] FIELDS_ALL_SINGLE_HOUSING = [ "id", "url", "type", "advert_type", "house_type", "title", "area", @@ -44,8 +42,7 @@ class PapTest(BackendTest, HousingTest): "photos", "rooms", "bedrooms", - "station", - "DPE" + "station" ] def test_pap_rent(self): @@ -96,8 +93,7 @@ def test_pap_viager(self): self.FIELDS_ANY_SINGLE_HOUSING = [ "photos", "bedrooms", - "station", - "DPE" + "station" ] self.check_against_query(query)