Exemple #1
0
    def set_product_data(self, page_url, soup, product_ctx):

        #
        #
        try:
            product_data = ProductData()
            crw_post_url = ''

            # 상품 카테고리
            #
            self.set_product_category_second(page_url, product_data, soup)

            ###########################
            # 상품 이미지 확인
            #
            ###########################
            self.set_product_image_fourth(product_data, product_ctx)

            ###########################
            # 상품명/URL
            ###########################
            crw_post_url = self.set_product_name_url_first(
                product_data, product_ctx, 'p', 'name')
            if (crw_post_url == ''):
                crw_post_url = self.set_product_name_url_first(
                    product_data, product_ctx, 'strong', 'name')

            ###########################
            # 가격
            #
            # <ul class="xans-element- xans-product xans-product-listitem spec"><li class=" xans-record-">
            # <strong class="title displaynone"><span style="font-size:12px;color:#828282;font-weight:bold;">소비자가</span> :</strong> <span style="font-size:12px;color:#828282;font-weight:bold;text-decoration:line-through;">72,800원</span></li>
            # <li class=" xans-record-">
            # <strong class="title displaynone"><span style="font-size:12px;color:#2e2828;font-weight:bold;">판매가</span> :</strong> <span style="font-size:12px;color:#2e2828;font-weight:bold;">품절</span></li>
            # <li class=" xans-record-">
            # <strong class="title displaynone"><span style="font-size:12px;color:#de546e;font-weight:bold;">상품요약정보</span> :</strong> <span style="font-size:12px;color:#de546e;font-weight:bold;">속방석 양면사용이 가능하며 커버분리도 가능해요</span></li>
            # </ul>
            ###########################
            li_list = product_ctx.find_all('li')
            for li_ctx in li_list:

                strong_ctx = li_ctx.find('strong')
                span_ctx = li_ctx.find_all('span')
                if (strong_ctx != None):
                    if (1 < len(span_ctx)):
                        title_name = strong_ctx.get_text().strip()
                        split_list = span_ctx[1].get_text().strip().split('(')
                        value_str = split_list[0].strip()

                        if (0 == title_name.find('브랜드')):
                            product_data.crw_brand1 = value_str
                        elif (0 == title_name.find('제조사')):
                            product_data.crw_brand2 = value_str
                        elif (0 == title_name.find('소비자가')):
                            product_data.crw_price = int(
                                __UTIL__.get_only_digit(value_str))
                        elif (0 == title_name.find('판매가')):
                            if (value_str == '품절'):
                                product_data.crw_is_soldout = 1
                                product_data.crw_price_sale = product_data.crw_price
                            else:
                                product_data.crw_price_sale = int(
                                    __UTIL__.get_only_digit(value_str))

            if (crw_post_url != ''):
                self.set_product_url_hash(product_data, crw_post_url)
                rtn = True

        except Exception as ex:
            __LOG__.Error('에러 : set_product_data')
            __LOG__.Error(ex)
            pass

        return True
Exemple #2
0
	def set_product_data(self , page_url, soup, product_ctx ) :
		
		# 
		#
		try :
			product_data = ProductData()
			crw_post_url = ''
			
			# 상품 카테고리
			#
			self.set_product_category_third(product_data, soup)
			#self.set_product_category_second(page_url, product_data, soup)
			
				
			###########################
			# 상품 이미지 확인
			#
			###########################
			self.set_product_image_first( product_data, product_ctx )

			# 품절여부 확인
			#
			#self.set_product_soldout_first(product_data, product_ctx ) 

			###########################
			# 상품명/URL
			###########################
			name_div_list = product_ctx.find_all('a', class_='name')
			
			for name_div_ctx in name_div_list :				
				if('href' in name_div_ctx.attrs ) : 
					name_value = name_div_ctx.get_text().strip()
					if(product_data.crw_name == '') : product_data.crw_name = name_value
						
					tmp_product_link = name_div_ctx.attrs['href'].strip()

					if(0 != tmp_product_link.find('http')) : tmp_product_link = '%s%s' % ( self.BASIC_PRODUCT_URL, name_div_ctx.attrs['href'].strip() )
					crw_post_url = tmp_product_link

					if(self.C_PRODUCT_STRIP_STR != '') : crw_post_url = tmp_product_link.replace( self.C_PRODUCT_STRIP_STR,'')

					split_list = crw_post_url.split('?product_no=')
					crw_goods_code_list = split_list[1].strip().split('&')
					product_data.crw_goods_code = crw_goods_code_list[0].strip()

					
			##############################
			# 가격
			#
			##############################
			li_list = product_ctx.find_all('li')
			for li_ctx in li_list :
				main_span_ctx = li_ctx.find('span')
				if( main_span_ctx != None) :
					strong_ctx = main_span_ctx.find('strong')
					span_ctx = main_span_ctx.find_all('span')
					if(strong_ctx != None) :
						if(1 < len(span_ctx) ) :
							title_name = strong_ctx.get_text().strip()
							split_list = span_ctx[2].get_text().strip().split('(')
							value_str = split_list[0].strip()

							if( 0 == title_name.find( '브랜드')) : product_data.crw_brand1 = value_str
							elif( 0 == title_name.find( '제조사')) : product_data.crw_brand2 = value_str
							elif( 0 == title_name.find( '소비자가')) : product_data.crw_price = int( __UTIL__.get_only_digit( value_str ) )
							elif( 0 == title_name.find( '판매가')) : product_data.crw_price_sale = int( __UTIL__.get_only_digit( value_str ))

				
			if( crw_post_url != '' ) :
				self.set_product_url_hash( product_data, crw_post_url) 
				rtn = True


		except Exception as ex:
			__LOG__.Error('에러 : set_product_data')
			__LOG__.Error(ex)
			pass
			
		return True	
Exemple #3
0
    def set_product_data(self, page_url, soup, product_ctx):

        #
        #
        try:
            product_data = ProductData()
            crw_post_url = ''

            # 상품 카테고리
            #
            #self.set_product_category_first(product_data, soup)
            self.set_product_category_second(page_url, product_data, soup)

            ###########################
            # 상품 이미지 확인
            #
            ###########################
            self.set_product_image_fourth(product_data, product_ctx)

            # 품절여부 확인
            #
            self.set_product_soldout_first(product_data, product_ctx)

            ###########################
            # 상품명/URL
            ###########################

            crw_post_url = self.set_product_name_url_first(
                product_data, product_ctx, 'div', '-name')

            ##############################
            # 가격
            # <div class="xans-element- xans-product xans-product-listitem -detail"><p rel="판매가" class=" xans-record-"><span class="title displaynone"><span style="font-size:12px;color:#008BCC;font-weight:bold;">판매가</span> :</span> <span class="-real"><span style="font-size:12px;color:#008BCC;font-weight:bold;">8,000원</span><span id="span_product_tax_type_text" style=""> </span></span></p>
            # <p rel="원산지" class=" xans-record-"><span class="title displaynone"><span style="font-size:12px;color:#555555;">원산지</span> :</span> <span class="-real"><span style="font-size:12px;color:#555555;">중국 yolan oem</span></span></p>
            # </div>
            ##############################
            p_list = product_ctx.find_all('p')
            for p_ctx in p_list:
                if ('rel' in p_ctx.attrs):
                    title_name = p_ctx.attrs['rel']
                    split_list = p_ctx.get_text().strip().split(':')
                    sub_split_list = split_list[1].strip().split('(')
                    value_str = sub_split_list[0].strip()
                    if (0 == title_name.find('브랜드')):
                        product_data.crw_brand1 = value_str
                    elif (0 == title_name.find('원산지')):
                        product_data.crw_brand2 = value_str
                    elif (0 == title_name.find('소비자가')):
                        product_data.crw_price = int(
                            __UTIL__.get_only_digit(value_str))
                    elif (0 == title_name.find('판매가')):
                        product_data.crw_price_sale = int(
                            __UTIL__.get_only_digit(value_str))

            if (crw_post_url != ''):
                self.set_product_url_hash(product_data, crw_post_url)
                rtn = True

        except Exception as ex:
            __LOG__.Error('에러 : set_product_data')
            __LOG__.Error(ex)
            pass

        return True
Exemple #4
0
    def set_product_data(self, page_url, soup, product_ctx):

        #
        #
        try:
            product_data = ProductData()
            crw_post_url = ''

            # 상품 카테고리
            #
            self.set_product_category_first(product_data, soup)

            ###########################
            # 상품 이미지 확인
            #
            # <img src="//ai-doggi.com/web/product/medium/20191220/a8ebb002293a954628763cf4a9ab6c38.jpg" alt="" class="thumb">
            ###########################
            self.set_product_image_second(product_data, product_ctx)

            # 품절여부 확인
            self.set_product_soldout_first(product_data, product_ctx)

            ###########################
            #
            # <p class="name">
            # <a href="/product/detail.html?product_no=286&amp;cate_no=43&amp;display_group=1"><strong class="title displaynone"><span style="font-size:12px;color:#555555;">상품명</span> :</strong> <span style="font-size:12px;color:#555555;">Frill Neck Sleeve Blouse Lavender [20%SALE]</span></a>
            # </p>
            ###########################

            crw_post_url = self.set_product_name_url_first(
                product_data, product_ctx, 'p', 'name')
            if (crw_post_url == ''):
                crw_post_url = self.set_product_name_url_first(
                    product_data, product_ctx, 'strong', 'name')

            ##############################
            #
            # <p class="price" style="padding:0px 0px 0px 0px;">
            # <span style="font-size:13px;"> <strike>33,000원</strike> &gt;
            # <span style="color:#f05e5e;  font-size:18px;"> <strong>17,000원</strong></span>
            # </span><span class="discount_rate " data-prod-custom="33000" data-prod-price="17000">48%</span></p>
            #
            ##############################

            price_p_list = product_ctx.find_all('li')
            for price_p_ctx in price_p_list:
                title_str = self.innerHTML(price_p_ctx)
                span_list = price_p_ctx.find_all('span')
                for span_ctx in span_list:
                    value_str = span_ctx.get_text().strip()
                    if (value_str != '') and (value_str != '샘플'):
                        if (0 < title_str.find('제조사')):
                            product_data.crw_brand2 = value_str
                        elif (0 < title_str.find('판매가')):
                            product_data.crw_price_sale = int(
                                __UTIL__.get_only_digit(value_str))

            if (crw_post_url != ''):
                self.set_product_url_hash(product_data, crw_post_url)
                rtn = True

        except Exception as ex:
            __LOG__.Error('에러 : set_product_data')
            __LOG__.Error(ex)
            pass

        return True