[logicimmo] fix : site changed

This commit is contained in:
Bezleputh 2015-06-03 15:41:07 +02:00 committed by Romain Bignon
commit bde6d0065d

View file

@ -23,7 +23,7 @@ from weboob.browser.pages import HTMLPage, JsonPage
from weboob.browser.elements import ItemElement, ListElement, DictElement, method from weboob.browser.elements import ItemElement, ListElement, DictElement, method
from weboob.browser.filters.json import Dict from weboob.browser.filters.json import Dict
from weboob.browser.filters.standard import Format, CleanText, Regexp, CleanDecimal, Date, Env, BrowserURL from weboob.browser.filters.standard import Format, CleanText, Regexp, CleanDecimal, Date, Env, BrowserURL
from weboob.browser.filters.html import XPath from weboob.browser.filters.html import XPath, CleanHTML
from weboob.capabilities.housing import Housing, HousingPhoto, City from weboob.capabilities.housing import Housing, HousingPhoto, City
from weboob.capabilities.base import NotAvailable from weboob.capabilities.base import NotAvailable
@ -52,65 +52,81 @@ class HousingPage(HTMLPage):
obj_title = CleanText('//meta[@itemprop="name"]/@content') obj_title = CleanText('//meta[@itemprop="name"]/@content')
obj_area = CleanDecimal(Regexp(CleanText('//meta[@itemprop="name"]/@content'), obj_area = CleanDecimal(Regexp(CleanText('//meta[@itemprop="name"]/@content'),
'(.*?)(\d*) m\xb2(.*?)', '\\2'), default=NotAvailable) '(.*?)(\d*) m\xb2(.*?)', '\\2'), default=NotAvailable)
obj_cost = CleanDecimal('//span[@itemprop="price"]') obj_cost = CleanDecimal('//div[@itemprop="price"]')
obj_currency = Regexp(CleanText('//span[@itemprop="price"]'), obj_currency = Regexp(CleanText('//div[@itemprop="price"]'),
'.*([%s%s%s])' % (u'', u'$', u'£'), default=u'') '.*([%s%s%s])' % (u'', u'$', u'£'), default=u'')
obj_date = Date(Regexp(CleanText('//p[@class="size_11 darkergrey"]'), u'.* Mis à jour : (\d{2}/\d{2}/\d{4}).*')) obj_date = Date(Regexp(CleanText('//p[@class="offer-description-notes"]'),
obj_text = CleanText('//div[@class="columns offer-description alpha"]') u'.* Mis à jour : (\d{2}/\d{2}/\d{4}).*'))
obj_location = CleanText('//span[@itemprop="address"]') obj_text = CleanHTML('//div[@class="offer-description-text"]')
obj_location = CleanText('//div[@itemprop="address"]')
obj_url = BrowserURL('housing', _id=Env('_id')) obj_url = BrowserURL('housing', _id=Env('_id'))
def obj_photos(self): def obj_photos(self):
photos = [] photos = []
for img in XPath('//div[@class="carousel"]/ul/li/a/img/@src')(self): for img in XPath('//div[@class="carousel-content"]/ul/li/a/img/@src')(self):
photos.append(HousingPhoto(u'%s' % img)) photos.append(HousingPhoto(u'%s' % img))
return photos return photos
def obj_details(self): def obj_details(self):
details = {} details = {}
a = CleanText('//div[@class="box box-noborder"]/p[@class="size_13 darkergrey bold"]')(self) energy = CleanText('//div[has-class("energy-summary")]/span[@class="section-label"]', default='')(self)
if a: energy_value = CleanText('//div[has-class("energy-summary")]/div[@class="arrow "]', default='')(self)
splitted_a = a.split(':') if energy and energy_value:
dpe = Regexp(CleanText('//div[@id="energy-pyramid"]/img/@src'), details[energy] = energy_value
'http://mmf.logic-immo.com/mmf/fr/static/dpe/dpe_(\w)_b.gif',
default="")(self) greenhouse = CleanText('//div[has-class("greenhouse-summary")]/span[@class="section-label"]',
if len(splitted_a) > 1: default='')(self)
details[splitted_a[0]] = '%s (%s)' % (splitted_a[1], dpe) greenhouse_value = CleanText('//div[has-class("greenhouse-summary")]/div[@class="arrow "]',
elif dpe: default='')(self)
details[splitted_a[0]] = '%s' if greenhouse and greenhouse_value:
details[greenhouse] = greenhouse_value
for li in XPath('//ul[@itemprop="description"]/li')(self):
label = CleanText('./div[has-class("criteria-label")]')(li)
value = CleanText('./div[has-class("criteria-value")]')(li)
details[label] = value
return details return details
def get_phone_url_datas(self): def get_phone_url_datas(self):
a = XPath('//a[has-class("phone-link")]')(self.doc)[0] a = XPath('//button[has-class("offer-contact-vertical-phone")]')(self.doc)[0]
urlcontact = CleanText('./@data-urlcontact')(a) urlcontact = 'http://www.logic-immo.com/modalMail'
params = {} params = {}
params['univers'] = CleanText('./@data-univers')(a) params['universe'] = CleanText('./@data-univers')(a)
params['source'] = CleanText('./@data-source')(a)
params['pushcontact'] = CleanText('./@data-pushcontact')(a) params['pushcontact'] = CleanText('./@data-pushcontact')(a)
params['mapper'] = CleanText('./@data-mapper')(a) params['mapper'] = CleanText('./@data-mapper')(a)
params['offerid'] = CleanText('./@data-offerid')(a) params['offerid'] = CleanText('./@data-offerid')(a)
params['offerflag'] = CleanText('./@data-offerflag')(a) params['offerflag'] = CleanText('./@data-offerflag')(a)
params['campaign'] = CleanText('./@data-campaign')(a) params['campaign'] = CleanText('./@data-campaign')(a)
params['xtpage'] = CleanText('./@data-xtpage')(a) params['xtpage'] = CleanText('./@data-xtpage')(a)
params['offertransactiontype'] = CleanText('./@data-offertransactiontype')(a)
params['aeisource'] = CleanText('./@data-aeisource')(a)
params['shownumber'] = CleanText('./@data-shownumber')(a)
params['corail'] = 1
return urlcontact, params return urlcontact, params
class SearchPage(HTMLPage): class SearchPage(HTMLPage):
@method @method
class iter_housings(ListElement): class iter_housings(ListElement):
item_xpath = '//article' item_xpath = '//div[@class="offer-block "]'
class item(ItemElement): class item(ItemElement):
klass = Housing klass = Housing
obj_id = Format('%s-%s', Env('type'), CleanText('./div/header/@id', replace=[('header-offer-', '')])) obj_id = Format('%s-%s', Env('type'), CleanText('./@id', replace=[('header-offer-', '')]))
obj_title = CleanText('./div/header/section/p[@class="property-type"]/span/@title') obj_title = CleanText('./div/div/div[@class="offer-details-wrapper"]/div/div/p[@class="offer-type"]/span/@title')
obj_area = CleanDecimal(Regexp(CleanText('./div/header/section/p[@class="property-type"]/span/@title'), obj_area = CleanDecimal(CleanText('./div/div/div[@class="offer-details-wrapper"]/div/div/div/div/h3/a/span[@class="offer-area-number"]',
'(.*?)(\d*) m\xb2(.*?)', '\\2'), default=NotAvailable) default=NotAvailable))
obj_cost = CleanDecimal(CleanText('./div/header/section/p[@class="price"]'), obj_cost = CleanDecimal(Regexp(CleanText('./div/div/div[@class="offer-details-wrapper"]/div/div/p[@class="offer-price"]/span',
replace_dots=(',', '.'), default=Decimal(0)) default=NotAvailable),
obj_currency = Regexp(CleanText('./div/header/section/p[@class="price"]'), '(.*) [%s%s%s]' % (u'', u'$', u'£'),
'.*([%s%s%s])' % (u'', u'$', u'£'), default=u'') default=NotAvailable), default=Decimal(0))
obj_date = Date(Regexp(CleanText('./div/header/section/p[has-class("update-date")]'), obj_currency = Regexp(CleanText('./div/div/div[@class="offer-details-wrapper"]/div/div/p[@class="offer-price"]/span',
default=NotAvailable),
'.* ([%s%s%s])' % (u'', u'$', u'£'), default=u'')
obj_date = Date(Regexp(CleanText('./div/div/div[has-class("offer-picture-more")]/div/p[@class="offer-update"]'),
".*(\d{2}/\d{2}/\d{4}).*")) ".*(\d{2}/\d{2}/\d{4}).*"))
obj_text = CleanText('./div/div[@class="content-offer"]/section[has-class("content-desc")]/p/span[@intemprop="adress"]') obj_text = CleanText('./div/div/div[@class="offer-details-wrapper"]/div/div/div/p[has-class("offer-description")]/span')
obj_location = CleanText('./div/div[@class="content-offer"]/section[has-class("content-desc")]/p/span[not(@intemprop)]') obj_location = CleanText('./div/div/div[@class="offer-details-wrapper"]/div/div/div/div/h2')