Fix pagination
Signed-off-by: Vicnet <vo.publique@gmail.com>
This commit is contained in:
parent
39ada3289f
commit
77984bf5fe
3 changed files with 10 additions and 5 deletions
|
|
@ -39,10 +39,13 @@ class LaCentraleBackend(BaseBackend, ICapPriceComparison):
|
|||
BROWSER = LaCentraleBrowser
|
||||
|
||||
# inherited from ICapPriceComparison
|
||||
def search_products(self, patterns=None):
|
||||
def search_products(self, patternString=None):
|
||||
# convert pattern to criteria
|
||||
criteria = { }
|
||||
for pattern in patterns.split(','):
|
||||
patterns = []
|
||||
if patternString:
|
||||
patterns = patternString.split(',')
|
||||
for pattern in patterns:
|
||||
pattern = pattern.lower()
|
||||
if u'€' in pattern:
|
||||
criteria['maxprice'] = pattern[:pattern.find(u'€')].strip()
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ class LaCentraleBrowser(BaseBrowser):
|
|||
'http://www.lacentrale.fr/': MainPage,
|
||||
'http://www.lacentrale.fr/listing_auto.php?.*': ListingAutoPage,
|
||||
}
|
||||
#http://www.lacentrale.fr/listing_auto.php?witchSearch=0&SS_CATEGORIE=40&mo_comm=&Citadine=citadine=&km_maxi=120000&annee2=&conso=&co2=&opt=&version=&transmission=&couleur=&nbportes=%3D5&photo=&new_annonce=&cp=31&origine=1
|
||||
|
||||
def iter_products(self, criteria):
|
||||
if not self.is_on_page(MainPage):
|
||||
|
|
@ -67,7 +66,7 @@ class LaCentraleBrowser(BaseBrowser):
|
|||
numpage = 1
|
||||
while True:
|
||||
# parse the current page
|
||||
for price in self.page.iter_prices(numpage):
|
||||
for price in self.page.iter_prices(product, numpage):
|
||||
yield price
|
||||
|
||||
# check if next page
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class ListingAutoPage(BasePage):
|
|||
return ''
|
||||
return td[-1].text_content().strip()
|
||||
|
||||
def iter_prices(self, numpage):
|
||||
def iter_prices(self, product, numpage):
|
||||
for tr in self.document.getroot().cssselect('tr.lcline[id],tr.lclineJB[id],tr.lclineJ[id]'):
|
||||
id = '{numpage}.{id}'.format(numpage=numpage, id=tr.attrib['id'][3:])
|
||||
title = self._extract(tr, 'lcbrand')
|
||||
|
|
@ -63,9 +63,12 @@ class ListingAutoPage(BasePage):
|
|||
cost = ', ' + self._extract(tr, 'lcprice')
|
||||
|
||||
price = Price(id)
|
||||
price.product = product
|
||||
price.cost = Decimal(re.findall(r'\d+',cost.replace(' ',''))[0])
|
||||
price.currency = u'€'
|
||||
price.message = unicode(title)
|
||||
price.shop = Shop(price.id)
|
||||
price.shop.set_empty_fields(NotAvailable)
|
||||
|
||||
price.set_empty_fields(NotAvailable)
|
||||
yield price
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue