def new_price(id, product, cost, title): price = Price(id) price.product = product price.cost = Decimal(get_decimal(cost)) price.currency = u'EUR' price.message = unicode(title) price.set_empty_fields(NotAvailable) price.shop = new_shop(id) return price
def iter_results(self, product=None): price = None product.name = self.get_product_name() for tr in self.document.getroot().cssselect('table#tab_resultat tr'): if tr.attrib.get('id', '').startswith('pdv'): price = Price('%s.%s' % (product.id, tr.attrib['id'][3:])) price.product = product tds = tr.findall('td') price.cost = Decimal(tds[4].text.replace(',', '.')) price.currency = u'€' shop = Shop(price.id) shop.name = unicode(tds[2].text.strip()) shop.location = unicode(tds[0].text.strip()) price.shop = shop price.set_empty_fields(NotAvailable) yield price
def iter_results(self, product=None): price = None product.name = self.get_product_name() for tr in self.document.getroot().cssselect('table#tab_resultat tr'): tds = self.parser.select(tr, 'td') if tds and len(tds) == 9 and product is not None: price = Price('%s.%s' % (product.id, tr.attrib['id'])) price.product = product price.cost = Decimal(tds[5].text.replace(',', '.')) price.currency = u'€' shop = Shop(price.id) shop.name = unicode(tds[3].text.strip()) shop.location = unicode(tds[2].text.strip()) price.shop = shop price.set_empty_fields(NotAvailable) yield price