Better id and some improvment
Signed-off-by: Vicnet <vo.publique@gmail.com>
This commit is contained in:
parent
4584384db7
commit
8f09828ebf
3 changed files with 138 additions and 95 deletions
|
|
@ -23,12 +23,13 @@ import re
|
|||
|
||||
from weboob.tools.browser import BaseBrowser
|
||||
|
||||
from .pages import MainPage, ListingAutoPage
|
||||
from .pages import MainPage, ListingAutoPage, AnnoncePage
|
||||
|
||||
|
||||
__all__ = ['LaCentraleBrowser']
|
||||
|
||||
|
||||
# I manage urls and page location, then trasnfert to page
|
||||
class LaCentraleBrowser(BaseBrowser):
|
||||
PROTOCOL = 'http'
|
||||
DOMAIN = 'www.lacentrale.fr'
|
||||
|
|
@ -36,6 +37,7 @@ class LaCentraleBrowser(BaseBrowser):
|
|||
PAGES = {
|
||||
'http://www.lacentrale.fr/': MainPage,
|
||||
'http://www.lacentrale.fr/listing_auto.php?.*': ListingAutoPage,
|
||||
'http://www.lacentrale.fr/auto-occasion-annonce-.*': AnnoncePage,
|
||||
}
|
||||
|
||||
def iter_products(self, criteria):
|
||||
|
|
@ -44,20 +46,22 @@ class LaCentraleBrowser(BaseBrowser):
|
|||
assert self.is_on_page(MainPage)
|
||||
return self.page.iter_products(criteria)
|
||||
|
||||
def buildUrl(self, product, request, criteria):
|
||||
def _buildUrl(self, product, request, criteria):
|
||||
if product._criteria.has_key(criteria):
|
||||
return '&' + request.format(product._criteria.get(criteria))
|
||||
return ''
|
||||
|
||||
def iter_prices(self, product):
|
||||
# convert product criteria to url encoding
|
||||
if not self.is_on_page(ListingAutoPage):
|
||||
#TODO use urllib.urlencode(data) ?
|
||||
url = '/listing_auto.php?num=1&witchSearch=0'
|
||||
url += self.buildUrl(product, 'Citadine={}','urban')
|
||||
url += self.buildUrl(product, 'prix_maxi={}','maxprice')
|
||||
url += self.buildUrl(product, 'km_maxi={}','maxdist')
|
||||
url += self.buildUrl(product, 'nbportes=%3D{}','nbdoors')
|
||||
url += self.buildUrl(product, 'cp={}','dept')
|
||||
url += self.buildUrl(product, 'origin={}','origin')
|
||||
url += self._buildUrl(product, 'Citadine={}','urban')
|
||||
url += self._buildUrl(product, 'prix_maxi={}','maxprice')
|
||||
url += self._buildUrl(product, 'km_maxi={}','maxdist')
|
||||
url += self._buildUrl(product, 'nbportes=%3D{}','nbdoors')
|
||||
url += self._buildUrl(product, 'cp={}','dept')
|
||||
url += self._buildUrl(product, 'origine={}','origin')
|
||||
#print url
|
||||
self.location(url)
|
||||
|
||||
|
|
@ -77,23 +81,8 @@ class LaCentraleBrowser(BaseBrowser):
|
|||
self.location(url)
|
||||
assert self.is_on_page(ListingAutoPage)
|
||||
|
||||
# def iter_prices(self, zipcode, product):
|
||||
# data = {'aff_param_0_0': '',
|
||||
# 'aff_param_0_1': 'les points de vente',
|
||||
# 'aff_param_0_3': zipcode,
|
||||
# 'changeNbPerPage': 'off',
|
||||
# 'toDelete': -1,
|
||||
# }
|
||||
# self.location('/index.php?module=dbgestion&action=search', urllib.urlencode(data))
|
||||
#
|
||||
# assert self.is_on_page(ComparisonResultsPage)
|
||||
# return self.page.iter_results(product)
|
||||
#
|
||||
# def get_shop_info(self, id):
|
||||
# data = {'pdv_id': id,
|
||||
# 'module': 'dbgestion',
|
||||
# 'action': 'getPopupInfo'}
|
||||
# self.location('/index.php?module=dbgestion&action=getPopupInfo', urllib.urlencode(data))
|
||||
#
|
||||
# assert self.is_on_page(ShopInfoPage)
|
||||
# return self.page.get_info()
|
||||
def get_price(self, id):
|
||||
#/auto-occasion-annonce-23440064.html
|
||||
self.location('/auto-occasion-annonce-'+id+'.html')
|
||||
assert self.is_on_page(AnnoncePage)
|
||||
return self.page.get_price(id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue