From e614af29dbee15bf58fa3433d18d189f69aeb4d4 Mon Sep 17 00:00:00 2001 From: Bezleputh Date: Fri, 14 Sep 2018 15:15:14 +0200 Subject: [PATCH] [explorimmo] fix module: website got updated --- modules/explorimmo/browser.py | 16 ++++++++-------- modules/explorimmo/pages.py | 13 ++++--------- modules/explorimmo/test.py | 4 ++-- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/modules/explorimmo/browser.py b/modules/explorimmo/browser.py index b74d6e4c8d..c029a787a1 100644 --- a/modules/explorimmo/browser.py +++ b/modules/explorimmo/browser.py @@ -25,14 +25,14 @@ class ExplorimmoBrowser(PagesBrowser): - BASEURL = 'https://www.explorimmo.com/' - - cities = URL('rest/locations\?q=(?P.*)', CitiesPage) - search = URL('resultat/annonces.html\?(?P.*)', SearchPage) - housing_html = URL('annonce-(?P<_id>.*).html', HousingPage) - phone = URL('rest/classifieds/(?P<_id>.*)/phone', PhonePage) - housing = URL('rest/classifieds/(?P<_id>.*)', - 'rest/classifieds/\?(?P.*)', HousingPage2) + BASEURL = 'https://immobilier.lefigaro.fr' + + cities = URL('/rest/locations\?q=(?P.*)', CitiesPage) + search = URL('/annonces/resultat/annonces.html\?(?P.*)', SearchPage) + housing_html = URL('/annonce-(?P<_id>.*).html', HousingPage) + phone = URL('/rest/classifieds/(?P<_id>.*)/phone', PhonePage) + housing = URL('/rest/classifieds/(?P<_id>.*)', + '/rest/classifieds/\?(?P.*)', HousingPage2) TYPES = {POSTS_TYPES.RENT: 'location', POSTS_TYPES.SALE: 'vente', diff --git a/modules/explorimmo/pages.py b/modules/explorimmo/pages.py index 4749f52842..dac434acbe 100644 --- a/modules/explorimmo/pages.py +++ b/modules/explorimmo/pages.py @@ -113,6 +113,7 @@ def condition(self): obj_id = Attr('.', 'data-classified-id') obj_type = Env('query_type') + obj_title = CleanText('./div/h2[@class="item-type"]') def obj_advert_type(self): if self.is_agency(): @@ -133,8 +134,6 @@ def obj_house_type(self): else: return HOUSE_TYPES.OTHER - obj_title = CleanText('.//*[has-class("js-item-title")]') - def obj_location(self): script = CleanText('./script')(self) try: @@ -163,7 +162,7 @@ def obj_cost(self): r'de (.*) à .*', default=0))(self) if cost == 0: - return CleanDecimal(self.price_selector, default=NotLoaded)(self) + return CleanDecimal(self.price_selector, default=NotAvailable)(self) else: return cost @@ -180,7 +179,7 @@ def obj_utilities(self): else: return UTILITIES.UNKNOWN - obj_text = CleanText('./div/div/div[@itemprop="description"]') + obj_text = CleanText('./div/p[@itemprop="description"]') obj_area = CleanDecimal( Regexp( obj_title, @@ -220,11 +219,7 @@ def obj_details(self): return NotLoaded def obj_photos(self): - url = Attr( - '.', - 'data-img', - default=None - )(self) + url = CleanText('./div[has-class("default-img")]/img/@data-src')(self) if url: url = unquote(url) if "http://" in url[3:]: diff --git a/modules/explorimmo/test.py b/modules/explorimmo/test.py index e005b2d0b6..f888a5c425 100644 --- a/modules/explorimmo/test.py +++ b/modules/explorimmo/test.py @@ -27,10 +27,10 @@ class ExplorimmoTest(BackendTest, HousingTest): FIELDS_ALL_HOUSINGS_LIST = [ "id", "type", "advert_type", "house_type", "title", "location", - "cost", "currency", "utilities", "text", "area", "url" + "utilities", "text", "area", "url" ] FIELDS_ANY_HOUSINGS_LIST = [ - "photos" + "photos", "cost", "currency" ] FIELDS_ALL_SINGLE_HOUSING = [ "id", "url", "type", "advert_type", "house_type", "title", "area", -- GitLab