Newer
Older
# -*- coding: utf-8 -*-
# Copyright(C) 2012 Romain Bignon
#
# This file is part of a weboob module.
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see <http://www.gnu.org/licenses/>.
from weboob.capabilities.housing import TypeNotSupported, POSTS_TYPES
from weboob.tools.compat import urlencode
from weboob.browser import PagesBrowser, URL
from .pages import SearchResultsPage, HousingPage, CitiesPage
from weboob.browser.profiles import Android
from .constants import TYPES, RET
class SeLogerBrowser(PagesBrowser):
BASEURL = 'http://www.seloger.com'
PROFILE = Android()
cities = URL('https://autocomplete.svc.groupe-seloger.com/auto/complete/0/Ville/6\?text=(?P<pattern>.*)', CitiesPage)
search = URL('https://ws-seloger.svc.groupe-seloger.com/search.xml\?(?P<request>.*)', SearchResultsPage)
housing = URL('https://ws-seloger.svc.groupe-seloger.com/annonceDetail.xml\?idAnnonce=(?P<_id>\d+)&noAudiotel=(?P<noAudiotel>\d)',
return self.cities.open(pattern=pattern).iter_cities()
def search_housings(self, type, cities, nb_rooms, area_min, area_max,
cost_min, cost_max, house_types, advert_types):
raise TypeNotSupported()
'org': 'advanced_search',
'surfacemax': area_max or '',
'surfacemin': area_min or '',
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
if house_type in RET:
ret.append(RET.get(house_type))
return self.search.go(request=urlencode(data)).iter_housings(
return self.housing.go(_id=_id, noAudiotel=1).get_housing(obj=obj)