def parse_brand(response): brand = is_empty( response.xpath('//td[@itemprop="brand"]/@content').extract()) if not brand: brand = is_empty( response.xpath('//td[@itemprop="brand"]/text()').extract()) if brand: brand = brand.strip() return brand
def parse_brand(response): brand = is_empty(response.xpath( '//td[@itemprop="brand"]/@content').extract()) if not brand: brand = is_empty(response.xpath( '//td[@itemprop="brand"]/text()').extract()) if brand: brand = brand.strip() return brand
def _parse_features(self, response): features = [] features_name = response.xpath( '//div[contains(@class, "large-12")]/div[contains(@class, "large-5")]' '/div[contains(@class, "desc")]/h2/text()').extract() features_value = response.xpath( '//div[contains(@class, "large-12")]/div[contains(@class, "large-7")]' ) for f_name in features_name: index = features_name.index(f_name) features_value_content = features_value[index].xpath( './/p[@class="specsDescription"]' '/span/text()').extract() if features_value_content: features_value_content = features_value_content[0] else: features_value_content = is_empty( features_value[index].xpath('.//a/@href').extract()) feature = { f_name: self.clear_text(features_value_content) } if features_value_content else { f_name: "" } features.append(feature) return features