def search_housings(self, type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, house_types): if type not in self.TYPES: raise TypeNotSupported() self.session.headers.update({ 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }) data = { 'geo_objets_ids': ','.join(cities), 'surface[min]': area_min or '', 'surface[max]': area_max or '', 'prix[min]': cost_min or '', 'prix[max]': cost_max or '', 'produit': self.TYPES.get(type, 'location'), 'recherche': 1, 'nb_resultats_par_page': 40, } if nb_rooms: data['nb_pieces[min]'] = nb_rooms data['nb_pieces[max]'] = nb_rooms ret = [] for house_type in house_types: if house_type in self.RET: ret.append(self.RET.get(house_type)) _data = '%s%s%s' % (urlencode(data), '&typesbien%5B%5D=', '&typesbien%5B%5D='.join(ret)) return self.search_page.go(data=_data).iter_housings()
def search_housings(self, type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, house_types, advert_types): if type not in TYPES: raise TypeNotSupported() data = { 'ci': ','.join(cities), 'idtt': TYPES.get(type, 1), 'org': 'advanced_search', 'surfacemax': area_max or '', 'surfacemin': area_min or '', 'tri': 'd_dt_crea', } if type == POSTS_TYPES.SALE: data['pxmax'] = cost_max or '' data['pxmin'] = cost_min or '' else: data['px_loyermax'] = cost_max or '' data['px_loyermin'] = cost_min or '' if nb_rooms: data['nb_pieces'] = nb_rooms ret = [] for house_type in house_types: if house_type in RET: ret.append(RET.get(house_type)) if ret: data['idtypebien'] = ','.join(ret) return self.search.go(request=urlencode(data)).iter_housings( query_type=type, advert_types=advert_types)
def search_housings(self, type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, house_types): if type not in self.TYPES: raise TypeNotSupported() ret = [] for house_type in house_types: if house_type in self.RET: ret.append(self.RET.get(house_type)) data = {'location': ','.join(cities), 'areaMin': area_min or '', 'areaMax': area_max or '', 'priceMin': cost_min or '', 'priceMax': cost_max or '', 'transaction': self.TYPES.get(type, 'location'), 'recherche': '', 'mode': '', 'proximity': '0', 'roomMin': nb_rooms or '', 'page': '1' } query = '%s%s%s' % (urllib.urlencode(data), '&type=', '&type='.join(ret)) return self.search.go(query=query).iter_housings()
def search_housings(self, _type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, house_types, advert_types): price = '{}/{}'.format(cost_min or 'NaN', cost_max or 'Nan') surface = '{}/{}'.format(area_min or 'Nan', area_max or 'Nan') rooms = '' if nb_rooms: rooms = '&rooms={}'.format(nb_rooms if nb_rooms <= 5 else 5) viager = "" if _type not in TYPES: raise TypeNotSupported() elif _type != POSTS_TYPES.VIAGER: _type = '{}'.format(TYPES.get(_type)) viager = "&natures=1,2,4" else: _type = TYPES.get(_type) places = '|'.join(['{{ci:{}}}'.format(c) for c in cities]) places = '[{}]'.format(places) ret = ','.join([RET.get(t) for t in house_types if t in RET]) query = "projects={}{}&places={}&types={}&price={}&surface={}{}&enterprise=0&qsVersion=1.0"\ .format(_type, viager, places, ret, price, surface, rooms) return self.search.go(query=query, page_number=1).iter_housings( query_type=_type, advert_types=advert_types, ret=ret)
def search_housings(self, type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, house_types, advert_types): if type not in self.TYPES: raise TypeNotSupported() ret = [] if type == POSTS_TYPES.VIAGER: ret = ['Viager'] else: for house_type in house_types: if house_type in self.RET: ret.append(self.RET.get(house_type)) data = {'location': ','.join(cities).encode('iso 8859-1'), 'furnished': type == POSTS_TYPES.FURNISHED_RENT, 'areaMin': area_min or '', 'areaMax': area_max or '', 'priceMin': cost_min or '', 'priceMax': cost_max or '', 'transaction': self.TYPES.get(type, 'location'), 'recherche': '', 'mode': '', 'proximity': '0', 'roomMin': nb_rooms or '', 'page': '1'} query = u'%s%s%s' % (urlencode(data), '&type=', '&type='.join(ret)) return self.search.go(query=query).iter_housings( query_type=type, advert_types=advert_types )
def search_housings(self, type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, house_types): if type not in self.TYPES: raise TypeNotSupported() options = [] ret = [] if type == POSTS_TYPES.VIAGER: ret = ['15'] else: for house_type in house_types: if house_type in self.RET: ret.append(self.RET.get(house_type)) if len(ret): options.append('groupprptypesids=%s' % ','.join(ret)) if type == POSTS_TYPES.FURNISHED_RENT: options.append('searchoptions=4') options.append('pricemin=%s' % (cost_min if cost_min else '0')) if cost_max: options.append('pricemax=%s' % cost_max) options.append('areamin=%s' % (area_min if area_min else '0')) if area_max: options.append('areamax=%s' % area_max) if nb_rooms: if type == POSTS_TYPES.SHARING: options.append('nbbedrooms=%s' % ','.join([str(i) for i in range(nb_rooms, 7)])) else: options.append('nbrooms=%s' % ','.join([str(i) for i in range(nb_rooms, 7)])) self.search.go(type=self.TYPES.get(type, 'location-immobilier'), cities=cities, options='/'.join(options)) if type == POSTS_TYPES.SHARING: return self.page.iter_sharing() return self.page.iter_housings(query_type=type)
def search_housings(self, query, advert_type, module_name): if query.type not in self.TYPES: return TypeNotSupported() type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, ret = self.decode_query( query, module_name) if len(cities) == 0 or len(ret) == 0: return list() return self.search.go( location=cities, ros=nb_rooms, sqs=area_min, sqe=area_max, _ps="mrs" if query.type == Query.TYPE_RENT else "ps", ps=cost_min, _pe="mre" if query.type == Query.TYPE_RENT else "pe", pe=cost_max, type=type, advert_type=advert_type, ret=ret).get_housing_list()
def search_housings(self, query, module_name): if query.type not in self.TYPES.keys(): return TypeNotSupported() data = {} data['filters'] = {} data['filters']['category'] = {} data['filters']['category']['id'] = self.TYPES.get(query.type) data['filters']['enums'] = {} data['filters']['enums']['ad_type'] = ['offer'] data['filters']['enums']['real_estate_type'] = [] for t in query.house_types: t = self.RET.get(t) if t: data['filters']['enums']['real_estate_type'].append(t) if query.type == POSTS_TYPES.FURNISHED_RENT: data['filters']['enums']['furnished'] = ['1'] elif query.type == POSTS_TYPES.RENT: data['filters']['enums']['furnished'] = ['2'] data['filters']['keywords'] = {} data['filters']['ranges'] = {} if query.cost_max or query.cost_min: data['filters']['ranges']['price'] = {} if query.cost_max: data['filters']['ranges']['price']['max'] = query.cost_max if query.cost_min: data['filters']['ranges']['price']['min'] = query.cost_min if query.area_max or query.area_min: data['filters']['ranges']['square'] = {} if query.area_max: data['filters']['ranges']['square']['max'] = query.area_max if query.area_min: data['filters']['ranges']['square']['min'] = query.area_min if query.nb_rooms: data['filters']['ranges']['rooms'] = {} data['filters']['ranges']['rooms']['min'] = query.nb_rooms data['filters']['location'] = {} data['filters']['location']['city_zipcodes'] = [] for c in query.cities: if c.backend == module_name: _c = c.id.split(' ') __c = {} __c['city'] = _c[0] __c['zipcode'] = _c[1] __c['label'] = c.name data['filters']['location']['city_zipcodes'].append(__c) if len(query.advert_types) == 1: if query.advert_types[0] == ADVERT_TYPES.PERSONAL: data['owner_type'] = 'private' elif query.advert_types[0] == ADVERT_TYPES.PROFESSIONAL: data['owner_type'] = 'pro' else: data['owner_type'] = 'all' data['limit'] = 100 data['limit_alu'] = 3 data['offset'] = 0 self.session.headers.update({"api_key": self.home.go().get_api_key()}) return self.api.go(data=json.dumps(data)).get_housing_list( query_type=query.type, data=data)