def items(self): for item in self.doc.xpath('//div[contains(@class,"a-box shipment")]' '/div/div/div/div/div/div'): url = (item.xpath(u'*//a[contains(@href,"/gp/product")]/@href') + [u''])[0] label = u''.join( item.xpath( '*//a[contains(@href,"/gp/product")]/text()')).strip() price = u''.join( x.strip() for x in item.xpath('*//span[contains(text(),"EUR")]/text()') if x.strip().startswith('EUR')) price = self.decimal_amount(price) multi = re.match(u'([0-9]+) de (.*)', label) if multi: amount, label = multi.groups() price *= Decimal(amount) if url: url = unicode(self.browser.BASEURL) + \ re.match(u'(/gp/product/.*)/ref=.*', url).group(1) if label and price: itm = Item() itm.label = label itm.url = url itm.price = price yield itm
def items(self): for shmt in self.shipments(): root = shmt.xpath(u'../../../../../../../..' u'//b[text()="Articles commandés"]')[0] for item in root.xpath('../../../tr')[1:]: count = url = label = None for div in item.xpath('*//div'): m = re.match(u'^\s*(\d+)\s*of:(.*)$', div.text, re.MULTILINE + re.DOTALL) if not m: continue count = Decimal(m.group(1).strip()) label = unicode(m.group(2).strip()) if label: url = u'' else: a = div.xpath('*//a[contains(@href,"/gp/product")]')[0] url = unicode(a.attrib['href']) label = unicode(a.text.strip()) price1 = item.xpath('*//div')[-1].text.strip() price = count * self.decimal_amount(price1) itm = Item() itm.label = label itm.url = url itm.price = price yield itm
def do_items(self, id): """ items [ID] Get items of orders. """ l = [] id, backend_name = self.parse_id(id, unique_backend=True) if not id: print('Error: please give a order ID (hint: use orders command)', file=self.stderr) return 2 else: l.append((id, backend_name)) for id, backend in l: names = (backend, ) if backend is not None else None # TODO: Use specific formatter mysum = Item() mysum.label = u"Sum" mysum.url = u"Generated by shopoob" mysum.price = Decimal("0.") self.start_format() for item in self.do('iter_items', id, backends=names): self.format(item) mysum.price = item.price + mysum.price self.format(mysum)
def do_items(self, id): """ items [ID] Get items of orders. """ l = [] id, backend_name = self.parse_id(id, unique_backend=True) if not id: print('Error: please give a order ID (hint: use orders command)', file=self.stderr) return 2 else: l.append((id, backend_name)) for id, backend in l: names = (backend,) if backend is not None else None # TODO: Use specific formatter mysum = Item() mysum.label = u"Sum" mysum.url = u"Generated by shopoob" mysum.price = Decimal("0.") self.start_format() for item in self.do('iter_items', id, backends=names): self.format(item) mysum.price = item.price + mysum.price self.format(mysum)
def items(self): for tr in self.doc.xpath('//tbody[@class="order-items"]/tr'): label = tr.xpath('*//h1')[0].text_content().strip() price = AmTr.decimal_amount(re.match(r'^\s*([^\s]+)(\s+.*)?', tr.xpath('*//div[@class="price"]')[0].text_content(), re.DOTALL).group(1)) url = 'http:' + tr.xpath('*//img/@src')[0] item = Item() item.label = unicode(label) item.url = unicode(url) item.price = price yield item
def items(self): for tr in self.doc.xpath('//tbody[@class="order-items"]/tr'): label = tr.xpath('*//h1')[0].text_content().strip() price = AmTr.decimal_amount( re.match(r'^\s*([^\s]+)(\s+.*)?', tr.xpath('*//div[@class="price"]')[0].text_content(), re.DOTALL).group(1)) url = 'http:' + tr.xpath('*//img/@src')[0] item = Item() item.label = unicode(label) item.url = unicode(url) item.price = price yield item
def items(self): for span in self.doc.xpath('//div[@class="shipmentItems1"]' '/span[@class="item"]'): url = span.xpath('span[@class="itemLink"]/a/@href')[0] label = span.xpath('span[@class="itemLink"]/a/text()')[0] qty = span.xpath('span[@class="itemQuantity"]/text()')[0] price = span.xpath('span[@class="itemPrice"]/text()')[0] price = Decimal(qty)*AmTr.decimal_amount(price) item = Item() item.url = unicode(url) item.label = cleanup(label) item.price = price yield item
def items(self): for tr in self.doc.xpath('//table[contains(@class,"items_table")]' '//tr[td[@class="items_desc"]]'): label = tr.xpath('*//div[@class="item_desc"]//span/text()')[0] url = tr.xpath('*//div[@class="item_img"]//@src')[0] onclk = tr.xpath('*//div[@class="item_img"]//@onclick') if onclk: url = re.match(r'window.open\(\'([^\']*)\'.*', onclk[0]).group(1) if url.startswith('/'): url = self.browser.BASEURL + url price = tr.xpath('td[@class="items_price"]/span/text()')[0] qty = tr.xpath('td[@class="items_qty"]//span/text()')[0] price = AmTr.decimal_amount(price) * Decimal(qty) item = Item() item.label = unicode(label) item.url = unicode(url) item.price = price yield item
def items(self): for item in self.doc.xpath('//div[contains(@class,"a-box shipment")]' "/div/div/div/div/div/div"): url = (item.xpath(u'*//a[contains(@href,"/gp/product")]/@href') + [u""])[0] label = u"".join(item.xpath('*//a[contains(@href,"/gp/product")]/text()')).strip() price = u"".join( x.strip() for x in item.xpath('*//span[contains(text(),"EUR")]/text()') if x.strip().startswith("EUR") ) price = self.decimal_amount(price) multi = re.match(u"([0-9]+) de (.*)", label) if multi: amount, label = multi.groups() price *= Decimal(amount) if url: url = unicode(self.browser.BASEURL) + re.match(u"(/gp/product/.*)/ref=.*", url).group(1) if label and price: itm = Item() itm.label = label itm.url = url itm.price = price yield itm
def items(self): for item in self.doc.xpath('//div[contains(@class,"a-box shipment")]' '/div/div/div/div/div/div'): url = (item.xpath(u'*//a[contains(@href,"/gp/product")]/@href') + [u''])[0] label = u''.join(item.xpath( '*//a[contains(@href,"/gp/product")]/text()')).strip() price = u''.join(x.strip() for x in item.xpath( '*//span[contains(text(),"$")]/text()') if x.strip().startswith('$')) price = AmTr.decimal_amount(price) multi = re.match(u'([0-9]+) of (.*)', label) if multi: amount, label = multi.groups() price *= Decimal(amount) if url: url = unicode(self.browser.BASEURL) + \ re.match(u'(/gp/product/.*)/ref=.*', url).group(1) if label: itm = Item() itm.label = label itm.url = url itm.price = price yield itm