def iter_products(self, criteria): product = Product(1) # TODO check if criteria exists in main page # and get the GET keyword to fill request ? product.name = unicode('Occasion') product._criteria = criteria yield product
def get_price(self, id, price=None): product = Product(id.split('.')[0]) product.backend = self.name price = find_object(self.iter_prices([product]), id=id, error=PriceNotFound) price.shop.info = self.browser.get_shop_info(price.id.split('.', 2)[-1]) return price
def iter_products(self): for li in self.parser.select(self.document.getroot(), 'div#choix_carbu ul li'): input = li.find('input') label = li.find('label') product = Product(input.attrib['value']) product.name = unicode(label.text.strip()) if '&' in product.name: # "E10 & SP95" produces a non-supported table. continue yield product
def get_price(self, id): for e in self.document.getroot().cssselect('div#DescBar'): product = Product(1) product.name = unicode('Occasion') cost = self._extract(e, 'PriceLc') title = self._extract(e, 'BrandLc') title += ', ' + self._extract(e, 'modeleCom') title += ', ' + self._extract_info(e, 'Version') title += ', ' + self._extract_info(e, 'Ann') title += ', ' + get_decimal(self._extract_info(e, 'Kilom')) + 'km' price = new_price(id, product, cost, title) price.shop = self.get_shop(id) return price
def get_price(self, id): for e in self.document.getroot().cssselect("div#DescBar"): product = Product(1) product.name = unicode("Occasion") cost = self._extract(e, "PriceLc") title = self._extract(e, "BrandLc") title += ", " + self._extract(e, "modeleCom") title += ", " + self._extract_info(e, "Version") title += ", " + self._extract_info(e, "Ann") title += ", " + get_decimal(self._extract_info(e, "Kilom")) + "km" price = new_price(id, product, cost, title) price.shop = self.get_shop(id) return price
def get_price(self, id): with self.browser: if isinstance(id, Price): price = id else: p_id, s_id = id.split('.', 2) product = Product(p_id) for price in self.iter_prices(product): if price.id == id: break else: return None price.shop.info = self.browser.get_shop_info(price.id.split('.', 2)[-1]) return price