[leboncoin] add regions support
This commit is contained in:
parent
689fe43ed5
commit
9d2b12c531
2 changed files with 42 additions and 5 deletions
|
|
@ -25,8 +25,8 @@ from .pages import CityListPage, HousingListPage, HousingPage
|
||||||
class LeboncoinBrowser(PagesBrowser):
|
class LeboncoinBrowser(PagesBrowser):
|
||||||
BASEURL = 'http://www.leboncoin.fr'
|
BASEURL = 'http://www.leboncoin.fr'
|
||||||
city = URL('ajax/location_list.html\?city=(?P<city>.*)&zipcode=(?P<zip>.*)', CityListPage)
|
city = URL('ajax/location_list.html\?city=(?P<city>.*)&zipcode=(?P<zip>.*)', CityListPage)
|
||||||
search = URL('(?P<type>.*)/offres/ile_de_france/occasions/\?ps=(?P<ps>.*)&pe=(?P<pe>.*)&ros=(?P<ros>.*)&location=(?P<location>.*)&sqs=(?P<sqs>.*)&sqe=(?P<sqe>.*)&ret=(?P<ret>.*)&f=(?P<advert_type>.*)',
|
search = URL('(?P<type>.*)/offres/(?P<region>.*)/occasions/\?ps=(?P<ps>.*)&pe=(?P<pe>.*)&ros=(?P<ros>.*)&location=(?P<location>.*)&sqs=(?P<sqs>.*)&sqe=(?P<sqe>.*)&ret=(?P<ret>.*)&f=(?P<advert_type>.*)',
|
||||||
'(?P<_type>.*)/offres/ile_de_france/occasions.*?',
|
'(?P<_type>.*)/offres/(?P<_region>.*)/occasions.*?',
|
||||||
HousingListPage)
|
HousingListPage)
|
||||||
housing = URL('ventes_immobilieres/(?P<_id>.*).htm', HousingPage)
|
housing = URL('ventes_immobilieres/(?P<_id>.*).htm', HousingPage)
|
||||||
|
|
||||||
|
|
@ -36,6 +36,10 @@ class LeboncoinBrowser(PagesBrowser):
|
||||||
Query.HOUSE_TYPES.PARKING: '4',
|
Query.HOUSE_TYPES.PARKING: '4',
|
||||||
Query.HOUSE_TYPES.OTHER: '5'}
|
Query.HOUSE_TYPES.OTHER: '5'}
|
||||||
|
|
||||||
|
def __init__(self, region, *args, **kwargs):
|
||||||
|
super(LeboncoinBrowser, self).__init__(*args, **kwargs)
|
||||||
|
self.region = region
|
||||||
|
|
||||||
def get_cities(self, pattern):
|
def get_cities(self, pattern):
|
||||||
city = ''
|
city = ''
|
||||||
zip_code = ''
|
zip_code = ''
|
||||||
|
|
@ -48,7 +52,8 @@ class LeboncoinBrowser(PagesBrowser):
|
||||||
|
|
||||||
def search_housings(self, query, advert_type):
|
def search_housings(self, query, advert_type):
|
||||||
type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, ret = self.decode_query(query)
|
type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, ret = self.decode_query(query)
|
||||||
return self.search.go(location=cities,
|
return self.search.go(region=self.region,
|
||||||
|
location=cities,
|
||||||
ros=nb_rooms,
|
ros=nb_rooms,
|
||||||
sqs=area_min,
|
sqs=area_min,
|
||||||
sqe=area_max,
|
sqe=area_max,
|
||||||
|
|
@ -81,7 +86,7 @@ class LeboncoinBrowser(PagesBrowser):
|
||||||
if query.type == Query.TYPE_RENT:
|
if query.type == Query.TYPE_RENT:
|
||||||
_type = 'locations'
|
_type = 'locations'
|
||||||
|
|
||||||
self.search.go(_type=_type)
|
self.search.go(_type=_type, _region=self.region)
|
||||||
|
|
||||||
nb_rooms = '' if not query.nb_rooms else self.page.get_rooms_min(query.nb_rooms)
|
nb_rooms = '' if not query.nb_rooms else self.page.get_rooms_min(query.nb_rooms)
|
||||||
area_min = '' if not query.area_min else self.page.get_area_min(query.area_min)
|
area_min = '' if not query.area_min else self.page.get_area_min(query.area_min)
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,39 @@ class LeboncoinModule(Module, CapHousing):
|
||||||
BROWSER = LeboncoinBrowser
|
BROWSER = LeboncoinBrowser
|
||||||
|
|
||||||
CONFIG = BackendConfig(Value('advert_type', label='Advert type',
|
CONFIG = BackendConfig(Value('advert_type', label='Advert type',
|
||||||
choices={'c': 'Agency', 'p': 'Owner', 'a': 'All'}, default='a'))
|
choices={'c': 'Agency', 'p': 'Owner', 'a': 'All'}, default='a'),
|
||||||
|
Value('region', label='Region',
|
||||||
|
choices=['alsace',
|
||||||
|
'aquitaine',
|
||||||
|
'auvergne',
|
||||||
|
'basse_normandie',
|
||||||
|
'bourgogne',
|
||||||
|
'bretagne',
|
||||||
|
'centre',
|
||||||
|
'champagne_ardenne',
|
||||||
|
'corse',
|
||||||
|
'franche_comte',
|
||||||
|
'haute_normandie',
|
||||||
|
'ile_de_france',
|
||||||
|
'languedoc_roussillon',
|
||||||
|
'limousin',
|
||||||
|
'lorraine',
|
||||||
|
'midi_pyrenees',
|
||||||
|
'nord_pas_de_calais',
|
||||||
|
'pays_de_la_loire',
|
||||||
|
'picardie',
|
||||||
|
'poitou_chanrentes',
|
||||||
|
'provence_alpes_cote_d_azur',
|
||||||
|
'rhone_alpes',
|
||||||
|
'guadeloupe',
|
||||||
|
'martinique',
|
||||||
|
'guyane',
|
||||||
|
'reunion']))
|
||||||
|
|
||||||
|
|
||||||
|
def create_default_browser(self):
|
||||||
|
region = self.config['region'].get()
|
||||||
|
return self.create_browser(region)
|
||||||
|
|
||||||
def get_housing(self, _id):
|
def get_housing(self, _id):
|
||||||
return self.browser.get_housing(_id)
|
return self.browser.get_housing(_id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue