def _parse_stock_status(self, response): stock_value = self.STOCK_STATUS['CALL_FOR_AVAILABILITY'] stock_status = extract_first( response.xpath('//span[@id="productAvailability"]/text()')) stock_status = stock_status.lower() if stock_status == 'out of stock': stock_value = self.STOCK_STATUS['OUT_OF_STOCK'] elif stock_status == 'in stock': stock_value = self.STOCK_STATUS['IN_STOCK'] elif stock_status == 'call for availability': stock_value = self.STOCK_STATUS['CALL_FOR_AVAILABILITY'] elif stock_status == 'discontinued': stock_value = self.STOCK_STATUS['OTHER'] return stock_value
def _parse_stock_status(response): stock_value = 4 stock_status = extract_first(response.xpath('//span[@id="productAvailability"]/text()')) stock_status = stock_status.lower() if stock_status == 'out of stock': stock_value = 0 if stock_status == 'in stock': stock_value = 1 if stock_status == 'call for availability': stock_value = 2 if stock_status == 'discontinued': stock_value = 3 return stock_value
def _parse_stock_status(response): stock_value = 4 stock_status = extract_first(response.xpath('//span[@id="productAvailability"]/text()')) stock_status = stock_status.lower() if stock_status == 'out of stock': stock_value = 0 if stock_status == 'in stock': stock_value = 1 if stock_status == 'call for availability': stock_value = 2 if stock_status == 'discontinued': stock_value = 3 return stock_value
def _parse_retailer_key(self, response): retailer_key = extract_first(response.xpath('//span[@itemprop="sku"]/text()')) return clean_text(self, retailer_key)
def _parse_sku(self, response): sku = extract_first(response.xpath('//span[@itemprop="sku"]/text()')) return clean_text(self, sku)
def _parse_price(response): price = extract_first(response.xpath('//span[@class="product-price"]' '/span[@class="priceDisplay"]/text()')) if price: return float(price.replace("$", "").replace(",", ""))
def _parse_model(self, response): model = extract_first(response.xpath('//span[@itemprop="mpn"]/text()')) return clean_text(self, model)
def _parse_image(response): image_url = extract_first(response.xpath('//a[@item-prop="image"]/@href')) return image_url
def _parse_brand(self, response): brand = response.xpath('//span[@itemprop="brand"]/text()') if brand: return extract_first(brand) return self.searchterm.upper()
def _parse_image(response): image_url = extract_first(response.xpath('//a[@item-prop="image"]/@href')) return image_url
def _parse_name(response): name = extract_first(response.xpath('//h1[@class="pagetitle"]/text()')) return name
def _parse_shippingphrase(response): shipping_phrase = extract_first(response.xpath('//span[@id="productEstimatedShipping"]/text()')) return shipping_phrase
def _parse_retailer_key(self, response): retailer_key = extract_first(response.xpath('//span[@itemprop="sku"]/text()')) return clean_text(self, retailer_key)
def _parse_sku(self, response): sku = extract_first(response.xpath('//span[@itemprop="sku"]/text()')) return clean_text(self, sku)
def _parse_price(response): price = extract_first(response.xpath('//span[@class="product-price"]' '/span[@class="priceDisplay"]/text()')) if price: return float(price.replace("$", "").replace(",", ""))
def _parse_model(self, response): model = extract_first(response.xpath('//span[@itemprop="mpn"]/text()')) return clean_text(self, model)
def _parse_shippingphrase(response): shipping_phrase = extract_first(response.xpath('//span[@id="productEstimatedShipping"]/text()')) return shipping_phrase
def _parse_name(response): name = extract_first(response.xpath('//h1[@class="pagetitle"]/text()')) return name
def _parse_brand(self, response): brand = response.xpath('//span[@itemprop="brand"]/text()') if brand: return extract_first(brand) return 'HP'