add parameter 'nb_rooms' in queries
This commit is contained in:
parent
825dc0b5b1
commit
b6379f7f37
9 changed files with 71 additions and 7 deletions
|
|
@ -41,7 +41,7 @@ class PapBackend(BaseBackend, ICapHousing):
|
|||
return list()
|
||||
|
||||
with self.browser:
|
||||
return self.browser.search_housings(cities,
|
||||
return self.browser.search_housings(cities, query.nb_rooms,
|
||||
query.area_min, query.area_max,
|
||||
query.cost_min, query.cost_max)
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class PapBrowser(BaseBrowser):
|
|||
fp = self.openurl(self.buildurl('http://www.pap.fr/index/ac-geo', q=pattern))
|
||||
return json.load(fp)
|
||||
|
||||
def search_housings(self, cities, area_min, area_max, cost_min, cost_max):
|
||||
def search_housings(self, cities, nb_rooms, area_min, area_max, cost_min, cost_max):
|
||||
data = {'geo_objets_ids': ','.join(cities),
|
||||
'surface[min]': area_min or '',
|
||||
'surface[max]': area_max or '',
|
||||
|
|
@ -54,6 +54,11 @@ class PapBrowser(BaseBrowser):
|
|||
'submit': 'rechercher',
|
||||
'typesbien[]': 'appartement',
|
||||
}
|
||||
|
||||
if nb_rooms:
|
||||
data['nb_pieces[min]'] = nb_rooms
|
||||
data['nb_pieces[max]'] = nb_rooms
|
||||
|
||||
self.location('/annonce/', urllib.urlencode(data))
|
||||
assert self.is_on_page(SearchResultsPage)
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class SeLogerBackend(BaseBackend, ICapHousing):
|
|||
return list([])
|
||||
|
||||
with self.browser:
|
||||
return self.browser.search_housings(cities,
|
||||
return self.browser.search_housings(cities, query.nb_rooms,
|
||||
query.area_min, query.area_max,
|
||||
query.cost_min, query.cost_max)
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class SeLogerBrowser(BaseBrowser):
|
|||
fp = self.openurl(self.buildurl('http://www.seloger.com/js,ajax,villequery_v3.htm', ville=pattern, mode=1))
|
||||
return json.load(fp)
|
||||
|
||||
def search_housings(self, cities, area_min, area_max, cost_min, cost_max):
|
||||
def search_housings(self, cities, nb_rooms, area_min, area_max, cost_min, cost_max):
|
||||
data = {'ci': ','.join(cities),
|
||||
'idtt': 1, #location
|
||||
'idtypebien': 1, #appart
|
||||
|
|
@ -54,6 +54,9 @@ class SeLogerBrowser(BaseBrowser):
|
|||
'tri': 'd_dt_crea',
|
||||
}
|
||||
|
||||
if nb_rooms:
|
||||
data['nb_pieces'] = nb_rooms
|
||||
|
||||
self.location(self.buildurl('http://ws.seloger.com/search.xml', **data))
|
||||
|
||||
assert self.is_on_page(SearchResultsPage)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class HousingPage(BasePage):
|
|||
|
||||
housing.title = details.find('titre').text
|
||||
housing.text = details.find('descriptif').text.strip()
|
||||
housing.cost = int(details.find('prix').text)
|
||||
housing.cost = float(details.find('prix').text)
|
||||
housing.currency = u'€'
|
||||
housing.date = parse_date(details.find('dtfraicheur').text)
|
||||
housing.area = float(details.find('surface').text)
|
||||
|
|
@ -92,4 +92,6 @@ class HousingPage(BasePage):
|
|||
for detail in details.xpath('./details/detail'):
|
||||
housing.details[detail.find('libelle').text.strip()] = detail.find('valeur').text or 'N/A'
|
||||
|
||||
housing.details['Reference'] = details.find('reference').text
|
||||
|
||||
return housing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue