def next_page(self): page_nb = Dict('navigation/pagination/page')(self) max_results = Dict('navigation/counts/count')(self) results_per_page = Dict('navigation/pagination/resultsPerPage')( self) if int(max_results) / int(results_per_page) > int(page_nb): return BrowserURL('search', query=Env('query'), page_number=int(page_nb) + 1)(self)
def obj_details(self): details = {} for c in Dict('categories')(self): if c['criteria']: details[c['name']] = ' / '.join( [_['value'] for _ in c['criteria']]) for _, c in Dict('infos_acquereur')(self).items(): for key, value in c.items(): details[key] = value return details
def obj_type(self): transaction = Dict('characteristics/transaction')(self) if transaction == 'location': if Dict('characteristics/isFurnished')(self): return POSTS_TYPES.FURNISHED_RENT else: return POSTS_TYPES.RENT elif transaction == 'vente': type = Dict('characteristics/estateType')(self).lower() if 'viager' in type: return POSTS_TYPES.VIAGER else: return POSTS_TYPES.SALE else: return NotAvailable
def obj_photos(self): photos = [] for photo in Dict('photoList')(self): photos.append(HousingPhoto(photo['fullscreenUrl'])) return photos
def obj_utilities(self): are_fees_included = Dict('characteristics/areFeesIncluded', default=None)(self) if are_fees_included: return UTILITIES.INCLUDED else: return UTILITIES.EXCLUDED
def obj_address(self): address = Dict('address')(self) p = PostalAddress() p.street = address['street'] p.postal_code = address['zipCode'] p.city = address['city'] p.full_address = Field('location')(self) return p
def obj_photos(self): photos = [] for img in Dict('characteristics/images')(self): m = re.search('http://thbr\.figarocms\.net.*(http://.*)', img.get('xl')) if m: photos.append(HousingPhoto(m.group(1))) else: photos.append(HousingPhoto(img.get('xl'))) return photos
def obj_type(self): idType = Dict('idTransactionType')(self) try: type = next(k for k, v in TYPES.items() if v == idType) if type == POSTS_TYPES.FURNISHED_RENT: # SeLoger does not let us discriminate between furnished and not furnished. return POSTS_TYPES.RENT return type except StopIteration: return NotAvailable
def obj_house_type(self): type = Dict('characteristics/estateType')(self).lower() if 'appartement' in type: return HOUSE_TYPES.APART elif 'maison' in type: return HOUSE_TYPES.HOUSE elif 'parking' in type: return HOUSE_TYPES.PARKING elif 'terrain' in type: return HOUSE_TYPES.LAND else: return HOUSE_TYPES.OTHER
class item(ItemElement): klass = Housing def condition(self): return (Dict('cardType')(self) not in ['advertising', 'ali', 'localExpert'] and Dict('id', default=False)(self) and Dict('classifiedURL', default=False)(self)) obj_id = Dict('id') def obj_type(self): idType = int(Env('query_type')(self)) type = next(k for k, v in TYPES.items() if v == idType) if type == POSTS_TYPES.FURNISHED_RENT: # SeLoger does not let us discriminate between furnished and not furnished. return POSTS_TYPES.RENT return type def obj_title(self): return "{} - {} - {}".format( Dict('estateType')(self), " / ".join(Dict('tags')(self)), Field('location')(self)) def obj_advert_type(self): is_agency = Dict('contact/agencyId', default=False)(self) if is_agency: return ADVERT_TYPES.PROFESSIONAL else: return ADVERT_TYPES.PERSONAL obj_utilities = UTILITIES.EXCLUDED def obj_photos(self): photos = [] for photo in Dict('photos')(self): photos.append(HousingPhoto(photo)) return photos def obj_location(self): quartier = Dict('districtLabel')(self) quartier = quartier if quartier else '' ville = Dict('cityLabel')(self) ville = ville if ville else '' cp = Dict('zipCode')(self) cp = cp if cp else '' return u'%s %s (%s)' % (quartier, ville, cp) obj_url = Dict('classifiedURL') obj_text = Dict('description') obj_cost = CleanDecimal(Dict('pricing/price', default=NotLoaded), default=NotLoaded) obj_currency = Currency(Dict('pricing/price', default=NotLoaded), default=NotLoaded) obj_price_per_meter = CleanDecimal( Dict('pricing/squareMeterPrice'), default=PricePerMeterFilter)
def obj_type(self): try: breadcrumb = int(Dict('category_id')(self)) except ValueError: breadcrumb = None if breadcrumb == 11: return POSTS_TYPES.SHARING elif breadcrumb == 10: isFurnished = CleanText(PopDetail('furnished', default=' '))(self) if isFurnished.lower() == u'meublé': return POSTS_TYPES.FURNISHED_RENT else: return POSTS_TYPES.RENT else: return POSTS_TYPES.SALE
def obj_GES(self): GES = Dict("ges", default="")(self) if GES['status'] > 0: return NotAvailable else: return getattr(ENERGY_CLASS, GES['lettre'], NotAvailable)
def obj_rooms(self): # TODO: Why is roomCount a list? rooms = Dict('characteristics/roomCount', default=[])(self) if rooms: return TypeDecimal(rooms[0])(self) return NotAvailable
def obj_currency(self): propertyPrice = Dict('propertyPrice')(self) return propertyPrice['priceUnit']
def obj_DPE(self): DPE = Dict("energie", default="")(self) if DPE['status'] > 0: return NotAvailable else: return getattr(ENERGY_CLASS, DPE['lettre'], NotAvailable)
def obj_DPE(self): DPE = Dict( 'characteristics/energyConsumptionCategory', default="" )(self) return getattr(ENERGY_CLASS, DPE, NotAvailable)
def obj_cost(self): propertyPrice = Dict('propertyPrice')(self) return decimal.Decimal(propertyPrice['prix'])
def obj_GES(self): GES = Dict( 'characteristics/greenhouseGasEmissionCategory', default="" )(self) return getattr(ENERGY_CLASS, GES, NotAvailable)
def obj_title(self): return "{} - {} - {}".format( Dict('estateType')(self), " / ".join(Dict('tags')(self)), Field('location')(self))
def obj_house_type(self): naturebien = Dict('propertyNatureId')(self) try: return next(k for k, v in RET.items() if v == naturebien) except StopIteration: return NotLoaded
def obj_details(self): details = {} details['fees'] = Dict( 'characteristics/fees', default=NotAvailable )(self) details['agencyFees'] = Dict( 'characteristics/agencyFees', default=NotAvailable )(self) details['guarantee'] = Dict( 'characteristics/guarantee', default=NotAvailable )(self) details['bathrooms'] = Dict( 'characteristics/bathroomCount', default=NotAvailable )(self) details['creationDate'] = FromTimestamp( Dict( 'characteristics/creationDate', default=NotAvailable ), default=NotAvailable )(self) details['availabilityDate'] = Dict( 'characteristics/estateAvailabilityDate', default=NotAvailable )(self) details['exposure'] = Dict( 'characteristics/exposure', default=NotAvailable )(self) details['heatingType'] = Dict( 'characteristics/heatingType', default=NotAvailable )(self) details['floor'] = Dict( 'characteristics/floor', default=NotAvailable )(self) details['bedrooms'] = Dict( 'characteristics/bedroomCount', default=NotAvailable )(self) details['isFurnished'] = Dict( 'characteristics/isFurnished', default=NotAvailable )(self) rooms = Dict('characteristics/roomCount', default=[])(self) if len(rooms): details['rooms'] = rooms[0] details['available'] = Dict( 'characteristics/isAvailable', default=NotAvailable )(self) agency = Dict('agency', default=NotAvailable)(self) details['agency'] = ', '.join([ x for x in [ agency.get('corporateName', ''), agency.get('corporateAddress', ''), agency.get('corporatePostalCode', ''), agency.get('corporateCity', '') ] if x ]) return details
class item(ItemElement): klass = City obj_id = Dict('label') obj_name = Dict('label')
class item(ItemElement): klass = City obj_id = Dict('id') obj_name = Dict('name')
def obj_advert_type(self): is_agency = Dict('contact/agencyId', default=False)(self) if is_agency: return ADVERT_TYPES.PROFESSIONAL else: return ADVERT_TYPES.PERSONAL
class item(ItemElement): klass = City obj_id = Dict('Params/ci') obj_name = Dict('Display')
def obj_location(self): address = Dict('address')(self) return u'%s %s (%s)' % (address['neighbourhood'], address['city'], address['zipCode'])
def obj_photos(self): photos = [] for photo in Dict('photos')(self): photos.append(HousingPhoto(photo)) return photos
def condition(self): return Dict('lct_parent_id')(self) != '0'
def condition(self): return (Dict('cardType')(self) not in ['advertising', 'ali', 'localExpert'] and Dict('id', default=False)(self) and Dict('classifiedURL', default=False)(self))
class get_housing(ItemElement): klass = Housing def parse(self, el): self.agency_doc = el['agency'] self.el = el['advert'] obj_id = Dict('id') def obj_house_type(self): naturebien = Dict('propertyNatureId')(self) try: return next(k for k, v in RET.items() if v == naturebien) except StopIteration: return NotLoaded def obj_type(self): idType = Dict('idTransactionType')(self) try: type = next(k for k, v in TYPES.items() if v == idType) if type == POSTS_TYPES.FURNISHED_RENT: # SeLoger does not let us discriminate between furnished and not furnished. return POSTS_TYPES.RENT return type except StopIteration: return NotAvailable def obj_advert_type(self): if 'Agences' in self.agency_doc['type']: return ADVERT_TYPES.PROFESSIONAL else: return ADVERT_TYPES.PERSONAL def obj_photos(self): photos = [] for photo in Dict('photoList')(self): photos.append(HousingPhoto(photo['fullscreenUrl'])) return photos obj_title = Dict('title') def obj_location(self): address = Dict('address')(self) return u'%s %s (%s)' % (address['neighbourhood'], address['city'], address['zipCode']) def obj_address(self): address = Dict('address')(self) p = PostalAddress() p.street = address['street'] p.postal_code = address['zipCode'] p.city = address['city'] p.full_address = Field('location')(self) return p obj_text = Dict('description') def obj_cost(self): propertyPrice = Dict('propertyPrice')(self) return decimal.Decimal(propertyPrice['prix']) def obj_currency(self): propertyPrice = Dict('propertyPrice')(self) return propertyPrice['priceUnit'] obj_price_per_meter = PricePerMeterFilter() obj_area = CleanDecimal(Dict('surface')) def obj_url(self): return self.page.url def obj_phone(self): return self.agency_doc.get('agencyPhoneNumber', {}).get('value', NotAvailable) def obj_utilities(self): return NotLoaded # TODO obj_bedrooms = CleanDecimal(Dict('bedroomCount')) obj_rooms = CleanDecimal(Dict('numberOfRooms'))