Exemplo n.º 1
0
    def parse(self, response):
        item = Item()
        retailer_sku = self.extract_product_id(response)

        if not self.is_new_item(retailer_sku):
            return

        item['retailer_sku'] = retailer_sku
        item['name'] = self.extract_name(response)
        item['gender'] = self.extract_gender(response)
        item['spider_name'] = 'vipshop'
        item['brand'] = self.extract_brand(response)
        item['care'] = self.extract_care(response)
        item['url'] = response.url
        item['description'] = self.extract_description(response)
        item['market'] = self.extract_market()
        item['retailer'] = self.extract_retailer()
        item['trail'] = response.meta.get('trail', [])
        item['image_urls'] = self.extract_image_urls(response)
        item['category'] = self.extract_categories(response)
        item['skus'] = self.extract_skus(response)
        requests = self.extract_colour_requests(
            response) + self.extract_stock_detail_request(response)
        item['meta'] = {'requests': requests}

        return item_or_request(item)
Exemplo n.º 2
0
    def parse_stock_item(self, response):
        item = response.meta.get('item', {})
        stock_details = response.xpath('//text()').re_first(
            'stock_detail\({"items":(.*])')
        out_of_stock = [
            std['id'] for std in json.loads(stock_details) if std['stock'] == 0
        ]

        for sku in item['skus']:
            if int(item['skus'][sku]['id']) in out_of_stock:
                item['skus'][sku]['out_of_stock'] = True

        return item_or_request(item)
Exemplo n.º 3
0
 def parse_colour_item(self, response):
     item = response.meta.get('item', {})
     item['skus'].update(self.extract_skus(response))
     item['image_urls'] += self.extract_image_urls(response)
     return item_or_request(item)