예제 #1
0
	def set_product_data(self , page_url, soup, product_ctx ) :
		
		# 
		#
		try :
			product_data = ProductData()
			crw_post_url = ''
			
			# 상품 카테고리
			#
			split_list = self.PAGE_URL_HASH[page_url].split('|')
			idx = 0
			for split_data in split_list :
				idx += 1
				if(idx == 1 ) : product_data.crw_category1 = split_data.strip()
				elif(idx == 2 ) : product_data.crw_category2 = split_data.strip()
				elif(idx == 3 ) : product_data.crw_category3 = split_data.strip()
				

			# 상품 이미지 확인
			div_list = product_ctx.find_all('div', class_='thumbnail')
			for div_ctx in div_list :
				a_link_list = product_ctx.find_all('a')
				for a_link_ctx in a_link_list :
					img_list = a_link_ctx.find_all('img')
					for img_ctx in img_list :
						if('src' in img_ctx.attrs ) :
							img_src = img_ctx.attrs['src'].strip()
							if( img_src != '' ) :
								img_link = self.set_img_url( self.BASIC_IMAGE_URL, img_src )
								if(product_data.product_img == '') : product_data.product_img = self.get_hangul_url_convert( img_link )

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

			name_div_list = product_ctx.find_all('strong', class_='name')

			for name_div_ctx in name_div_list :
				#
				# 상품명 / 상품코드
				#
				product_link_list = name_div_ctx.find_all('a')
				for product_link_ctx in product_link_list :				
					if('href' in product_link_ctx.attrs ) : 
						product_data.crw_name = product_link_ctx.get_text().strip()
							
						tmp_product_link = product_link_ctx.attrs['href'].strip()
						if(0 != tmp_product_link.find('http')) : tmp_product_link = '%s%s' % ( self.BASIC_PRODUCT_URL, product_link_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('/')
						if( product_data.crw_name == '') : product_data.crw_name = split_list[4].strip()
						product_data.crw_goods_code = split_list[5].strip()

				
			#
			# 가격 / 브랜드
			#

			div_list = product_ctx.find_all('div', class_='description')
			for div_ctx in div_list :
				span_list = div_ctx.find_all('span')
				for span_ctx in span_list :
					if('class' in span_ctx.attrs ) :
						class_name_list = span_ctx.attrs['class']
						if(len(class_name_list) == 1) and ( class_name_list[0].strip() == 'summary') : product_data.crw_brand1 = span_ctx.get_text().strip()
						
				li_list = div_ctx.find_all('li')
				for li_ctx in li_list :
					if('class' in li_ctx.attrs ) :
						class_name_list = li_ctx.attrs['class']
						if(len(class_name_list) == 1) and ( class_name_list[0].strip() == 'price') : product_data.crw_price = int( __UTIL__.get_only_digit( li_ctx.get_text().strip() ) )
						
			
			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	
예제 #2
0
    def set_product_data(self, page_url, soup, product_ctx):

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

            ####################################
            # 상품 이미지 확인
            # 상품 링크 정보 및 상품코드
            # 카테고리
            #
            # <div class="thumb salebox"> <a href="/shop/shopdetail.html?branduid=3356611&amp;xcode=002&amp;mcode=005&amp;scode=&amp;type=X&amp;sort=manual&amp;cur_code=002&amp;GfDT=aG13UQ%3D%3D"><img class="MS_prod_img_m" src="/shopimages/petnoriter/0020050000022.jpg?1590140914" alt="상품 섬네일"></a>
            # <input type="hidden" name="custom_price" value="49900">
            # <input type="hidden" name="product_price" value="28900">
            # <span class="sale_text" style="display: block;">42%</span> </div>
            #
            ####################################

            img_div_list = product_ctx.find_all('div', class_='thumb salebox')
            for img_div_ctx in img_div_list:
                product_link_list = img_div_ctx.find_all('a')
                img_list = img_div_ctx.find_all('img')
                for img_ctx in img_list:
                    img_src = ''
                    if ('src' in img_ctx.attrs):
                        split_list = img_ctx.attrs['src'].strip().split('?')
                        img_src = split_list[0].strip()

                    if (img_src != ''):
                        img_link = self.set_img_url(self.BASIC_IMAGE_URL,
                                                    img_src)
                        product_data.product_img = self.get_hangul_url_convert(
                            img_link)
                        break

                for product_link_ctx in product_link_list:
                    if ('href' in product_link_ctx.attrs):
                        crw_post_url = self.get_crw_post_url(
                            product_link_ctx, 'href')
                        if (crw_post_url != ''):
                            self.get_crw_goods_code(product_data, crw_post_url)
                            self.get_category_value(product_data, crw_post_url)
                            break

            ####################################
            # 상품명 및 브랜드
            #
            # <li class="dsc">논슬립 항균 배변 매트 원형/사각</li>
            ####################################
            name_strong_list = product_ctx.find_all('li', class_='dsc')
            for name_strong_ctx in name_strong_list:
                product_data.crw_name = name_strong_ctx.get_text().strip()
                #
                # 이름 앞에 브랜드명이 있음.
                # [스텔라&츄이] 츄이스 치킨 디너패티
                if (0 == product_data.crw_name.find('[')):
                    brand_list = product_data.crw_name.split(']')
                    product_data.crw_brand1 = brand_list[0][1:].strip()

            ####################################
            # 가격 / 품절 여부 확인
            #
            # <ul class="info">
            # <li class="dsc">논슬립 항균 배변 매트 원형/사각</li>
            # <li class="subname">배변걱정 이제그만~</li>
            # <li class="price">28,900원</li>
            # <li class="consumer">49,900원</li>
            # <li class="icon"><span class="MK-product-icons"></span></li>
            # <li class="closeup"><a class="btn-overlay-show" href="javascript:viewdetail('002005000002', '1', '');"><img src="/images/common/view_shopdetail2.gif" alt="미리보기"></a></li>
            # <li class="cboth icon_option"></li>
            # </ul>
            #
            #
            ####################################

            div_list = product_ctx.find_all('ul')
            for div_ctx in div_list:
                sell_ctx = div_ctx.find('li', class_='price')
                consumer_ctx = div_ctx.find('li', class_='consumer')
                soldout_ctx = div_ctx.find('li', class_='soldout')
                if (soldout_ctx != None): product_data.crw_is_soldout = 1

                if (consumer_ctx != None):
                    product_data.crw_price = int(
                        __UTIL__.get_only_digit(
                            consumer_ctx.get_text().strip()))

                if (sell_ctx != None):
                    product_data.crw_price_sale = int(
                        __UTIL__.get_only_digit(sell_ctx.get_text().strip()))

            if (crw_post_url != ''):
                #if( self.PRODUCT_URL_HASH.get( crw_post_url , -1) == -1) :

                self.set_product_data_sub(product_data, crw_post_url)

                self.process_product_api(product_data)

                rtn = True

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

        return True
예제 #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_first(product_data, product_ctx)

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

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

            crw_post_url = self.set_product_name_url_second(
                product_data, product_ctx, 'div', 'sp-product__title')

            ##############################
            # 가격
            #
            # <div class="xans-element- xans-product xans-product-listitem sp-product__listitem"><div rel="판매가" class="sp-product__listitem-opt product_price  xans-record-">
            # <span class="sp-product__subs displaynone"><span style="font-size:12px;color:#333333;font-weight:bold;">판매가</span></span><span style="font-size:12px;color:#333333;font-weight:bold;">25,000원</span><span id="span_product_tax_type_text" style=""> </span>             </div>
            ##############################
            price_ctx = product_ctx.find(
                'div',
                class_=
                'xans-element- xans-product xans-product-listitem sp-product__listitem'
            )

            if (price_ctx != None):
                div_list = price_ctx.find_all('div')
                for div_ctx in div_list:
                    value_str = div_ctx.get_text().strip()
                    # split_list = value_str.split(':')
                    # print(split_list)
                    if (0 == value_str.find('브랜드')):
                        product_data.crw_brand1 = value_str.strip()
                    elif (0 == value_str.find('판매가')):
                        product_data.crw_price = int(
                            __UTIL__.get_only_digit(value_str.strip()))
                    elif (0 == value_str.find('할인판매가')):
                        product_data.crw_price_sale = int(
                            __UTIL__.get_only_digit(value_str.strip()))

            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
예제 #4
0
    def set_product_data(self, page_url, soup, product_ctx):

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

            self.reset_product_category(product_data)

            category_ctx_list = soup.select(
                'body > div.body_wrap > div.content_wrap > div.section_tit > div.close'
            )

            for category_ctx in category_ctx_list:
                split_list = category_ctx.get_text().strip().split('>')
                idx = 0
                for split_data in split_list:
                    idx += 1
                    category_name = split_data.strip()
                    if (idx == 2): product_data.crw_category1 = category_name
                    elif (idx == 3): product_data.crw_category2 = category_name
                    elif (idx == 4): product_data.crw_category3 = category_name

            #split_list = self.PAGE_URL_HASH[page_url].split('(')
            #product_data.crw_category1 = split_list[0].replace('BEST','').strip()

            ####################################
            # 브랜드 추출
            #
            # <div class="line_sub">
            # 한국산				</div>
            ####################################

            div_list = product_ctx.find_all('div', class_='line_sub')
            for div_ctx in div_list:
                brand_str = div_ctx.get_text().strip()
                product_data.crw_brand1 = brand_str

            ####################################
            # 상품 이미지 확인 / 상품 링크 정보 / 상품번호
            #
            # <div class="picture"><a href="./product.html?pd_code=A010489&amp;event_type=%C3%CA%C6%AF%B0%A1"><img src="http://queenpuppy.co.kr/shop/pd_img/A01/489/A010489_2.jpg"></a></div>
            ####################################

            span_list = product_ctx.find_all('div', class_='picture')
            for span_ctx in span_list:
                product_link_ctx = span_ctx.find('a')
                if (product_link_ctx != None):
                    if ('href' in product_link_ctx.attrs):
                        tmp_product_link = product_link_ctx.attrs[
                            'href'].strip()
                        if (0 != tmp_product_link.find('http')):
                            tmp_product_link = '%s%s' % (
                                self.BASIC_PRODUCT_URL,
                                product_link_ctx.attrs['href'].strip())

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

                        split_list = crw_post_url.split('&event_type=')
                        crw_post_url = split_list[0].strip()

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

                    img_list = product_link_ctx.find_all('img')
                    for img_ctx in img_list:
                        img_src = ''
                        if ('data-original' in img_ctx.attrs):
                            img_src = img_ctx.attrs['data-original'].strip()
                        elif ('src' in img_ctx.attrs):
                            img_src = img_ctx.attrs['src'].strip()

                        if (img_src != ''):
                            img_link = self.set_img_url(
                                self.BASIC_IMAGE_URL, img_src)
                            product_data.product_img = self.get_hangul_url_convert(
                                img_link)

            ####################################
            # 상품명
            #
            # <div class="name">
            # <div style="color:#fd705f; font-weight: bold; valign:top; height: 15px; padding-bottom: 3px;"></div>
            # <a href="./product.html?pd_code=A010489&amp;event_type=%C3%CA%C6%AF%B0%A1">
            # 건국유업 프로젝트 닥터케이 펫밀크 10개입										</a>
            # </div>
            ####################################
            name_div_list = product_ctx.find_all('div', class_='name')
            for name_div_ctx in name_div_list:
                span_ctx = name_div_ctx.find('a')
                if (span_ctx != None):
                    crw_name = span_ctx.get_text().strip()
                    product_data.crw_name = crw_name
                    if (0 < crw_name.find('[품절]')):
                        product_data.crw_is_soldout = 1
                        product_data.crw_name = crw_name.replace('[품절]',
                                                                 '').strip()

            ####################################
            # 가격
            #
            #
            # <div class="line_np">20,000원</div>
            # <div class="line_sp">
            # 12,000원
            # <span style="font-size: 0.8em; color: #666; vertical-align:bottom;">40%↓</span>									</div>
            ####################################

            div_list = product_ctx.find_all('div', class_='line_np')
            for div_ctx in div_list:
                price_str = div_ctx.get_text().strip()
                product_data.crw_price = int(
                    __UTIL__.get_only_digit(price_str))

            div_list = product_ctx.find_all('div', class_='line_sp')
            for div_ctx in div_list:
                price_str = div_ctx.get_text().strip()
                span_ctx = div_ctx.find('span')
                split_str = ''
                if (span_ctx != None): split_str = span_ctx.get_text().strip()
                if (split_str == ''):
                    product_data.crw_price_sale = int(
                        __UTIL__.get_only_digit(price_str.strip()))
                else:
                    split_list = price_str.split(split_str)
                    product_data.crw_price_sale = int(
                        __UTIL__.get_only_digit(split_list[0].strip()))

            if (crw_post_url != ''):
                #if( self.PRODUCT_URL_HASH.get( crw_post_url , -1) == -1) :

                self.set_product_data_sub(product_data, crw_post_url)
                self.process_product_api(product_data)

                rtn = True

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

        return True
예제 #5
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
예제 #6
0
    def set_product_data(self, page_url, soup, product_ctx):

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

            ####################################
            # 상품 이미지 확인
            # 상품 링크 정보 및 상품코드
            # 카테고리
            #
            # <dt class="thumb"><a href="/shop/shopdetail.html?branduid=803964&amp;xcode=035&amp;mcode=003&amp;scode=&amp;type=Y&amp;sort=manual&amp;cur_code=035&amp;GfDT=aGV%2BVA%3D%3D"><img class="MS_prod_img_s" src="/shopimages/aromnaom/0330290001733.jpg?1581494094"></a></dt>
            #
            ####################################

            img_div_list = product_ctx.find_all('dt', class_='thumb')
            for img_div_ctx in img_div_list:
                product_link_list = img_div_ctx.find_all('a')
                img_list = img_div_ctx.find_all('img')
                for img_ctx in img_list:
                    img_src = ''
                    if ('src' in img_ctx.attrs):
                        split_list = img_ctx.attrs['src'].strip().split('?')
                        img_src = split_list[0].strip()

                    if (img_src != ''):
                        img_link = self.set_img_url(self.BASIC_IMAGE_URL,
                                                    img_src)
                        product_data.product_img = self.get_hangul_url_convert(
                            img_link)
                        break

                for product_link_ctx in product_link_list:
                    if ('href' in product_link_ctx.attrs):
                        crw_post_url = self.get_crw_post_url(
                            product_link_ctx, 'href')
                        if (crw_post_url != ''):
                            self.get_crw_goods_code(product_data, crw_post_url)
                            self.get_category_value(product_data, crw_post_url)
                            break

            ####################################
            # 상품명 및 브랜드
            #
            # <li class="prd-name">[애니케어] 면역을 위한 멀티파우더 <span class="MK-product-icons"></span></li>
            ####################################
            name_strong_list = product_ctx.find_all('li', class_='prd-name')
            for name_strong_ctx in name_strong_list:
                product_data.crw_name = name_strong_ctx.get_text().strip()
                #
                # 이름 앞에 브랜드명이 있음.
                # [스텔라&츄이] 츄이스 치킨 디너패티
                if (0 == product_data.crw_name.find('[')):
                    brand_list = product_data.crw_name.split(']')
                    product_data.crw_brand1 = brand_list[0][1:].strip()

            ####################################
            # 가격 / 품절 여부 확인
            #
            # <li class="prd-price">74,800원</li>
            #
            # ---- 품절시  -------
            # <li class="prd-price">
            # <span class="fc-red">품절</span>
            # </li>
            ####################################

            div_list = product_ctx.find_all('ul')
            for div_ctx in div_list:
                sell_ctx = div_ctx.find('li', class_='prd-price')
                if (sell_ctx != None):
                    product_data.crw_price_sale = int(
                        __UTIL__.get_only_digit(sell_ctx.get_text().strip()))
                    soldout_ctx = div_ctx.find('span', class_='fc-red')
                    if (soldout_ctx != None): product_data.crw_is_soldout = 1

            if (crw_post_url != ''):
                #if( self.PRODUCT_URL_HASH.get( crw_post_url , -1) == -1) :

                self.set_product_data_sub(product_data, crw_post_url)

                self.process_product_api(product_data)

                rtn = True

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

        return True
예제 #7
0
    def set_product_data(self, page_url, soup, product_ctx):

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

            ####################################
            # 상품 이미지 확인
            # 상품 링크 정보 및 상품코드
            # 카테고리
            #
            # <div class="thumb">
            # <a href="/shop/shopdetail.html?branduid=1000006164&amp;xcode=007&amp;mcode=006&amp;scode=001&amp;type=X&amp;sort=order&amp;cur_code=007&amp;GfDT=aWx3UQ%3D%3D"><img class="MS_prod_img_m" src="/shopimages/sizeoo/0070060000702.jpg?1589180862" onmouseover="this.src='/shopimages/sizeoo/007006000070.jpg?1589180862'" onmouseout="this.src='/shopimages/sizeoo/0070060000702.jpg?1589180862'" alt="" title=""></a>
            # </div>
            ####################################

            img_div_list = product_ctx.find_all('div', class_='thumb')
            for img_div_ctx in img_div_list:
                product_link_list = img_div_ctx.find_all('a')
                img_list = img_div_ctx.find_all('img')
                for img_ctx in img_list:
                    img_src = ''
                    if ('src' in img_ctx.attrs):
                        split_list = img_ctx.attrs['src'].strip().split('?')
                        img_src = split_list[0].strip()

                    if (img_src != ''):
                        img_link = self.set_img_url(self.BASIC_IMAGE_URL,
                                                    img_src)
                        product_data.product_img = self.get_hangul_url_convert(
                            img_link)
                        break

                for product_link_ctx in product_link_list:
                    if ('href' in product_link_ctx.attrs):
                        crw_post_url = self.get_crw_post_url(
                            product_link_ctx, 'href')
                        if (crw_post_url != ''):
                            self.get_crw_goods_code(product_data, crw_post_url)
                            self.get_category_value(product_data, crw_post_url)
                            break

            ####################################
            # 상품명 및 브랜드
            # <li class="name"><span class="MK-product-icons"></span> 데이지 비치 원피스 (옐로우)</li>
            ####################################
            name_strong_list = product_ctx.find_all('li', class_='name')
            for name_strong_ctx in name_strong_list:
                product_data.crw_name = name_strong_ctx.get_text().strip()
                #
                # 이름 앞에 브랜드명이 있음.
                # [스텔라&츄이] 츄이스 치킨 디너패티
                if (0 == product_data.crw_name.find('[')):
                    brand_list = product_data.crw_name.split(']')
                    product_data.crw_brand1 = brand_list[0][1:].strip()

            ####################################
            # 가격 / 품절 여부 확인
            #
            #
            # <li class="price">
            # <span><s>32,000</s>원</span>
            # 32,000원
            # </li>
            #
            #------------품절시 ----------------
            # <li class="price">
            # Sold Out
            # </li>
            ####################################

            div_list = product_ctx.find_all('li', class_='price')
            for div_ctx in div_list:
                sell_price = div_ctx.get_text().strip()
                consumer_ctx = div_ctx.find('span')

                consumer_price = ''
                if (consumer_ctx != None):
                    consumer_price = consumer_ctx.get_text().strip()
                    product_data.crw_price = int(
                        __UTIL__.get_only_digit(consumer_price))

                crw_price_sale = sell_price.replace(consumer_price, '').strip()
                product_data.crw_price_sale = int(
                    __UTIL__.get_only_digit(crw_price_sale))
                # 품절시 가격없이 Sold Out 문구 나옴.
                if (0 < crw_price_sale.strip().find('Out')):
                    product_data.crw_is_soldout = 1

            if (crw_post_url != ''):
                #if( self.PRODUCT_URL_HASH.get( crw_post_url , -1) == -1) :

                self.set_product_data_sub(product_data, crw_post_url)

                self.process_product_api(product_data)

                rtn = True

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

        return True
예제 #8
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)

            ###########################
            # 상품 이미지 확인
            #
            # <div class="prdImg">
            # <a href="/product/chicken-terrine/304/category/137/display/1/" name="anchorBoxName_304"><img src="//bymona.co.kr/web/product/medium/202008/35319c8b46eba6ca86653a26193b993d.jpg" id="eListPrdImage304_1" alt="chicken terrine"></a>
            # </div>
            ###########################
            self.set_product_image_fourth(product_data, product_ctx)

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

            ###########################
            #
            # <strong class="name"><a href="/product/chicken-terrine/304/category/137/display/1/" class=""><span class="title displaynone"><span style="font-size:12px;color:#555555;">상품명</span> :</span> <span style="font-size:12px;color:#555555;">chicken terrine</span></a></strong>
            ###########################

            crw_post_url = self.set_product_name_url_second(
                product_data, product_ctx, 'strong', 'name')

            ############################
            #
            # <ul class="xans-element- xans-product xans-product-listitem left"><li class=" xans-record-">
            # <span class="title displaynone"><span style="font-size:12px;color:#000000;font-weight:bold;">판매가</span> :</span> <span style="font-size:12px;color:#000000;font-weight:bold;">4,000 won</span><span id="span_product_tax_type_text" style=""> </span></li>
            # </ul>
            #
            ############################
            li_list = product_ctx.find_all('li')
            for li_ctx in li_list:
                value_str = li_ctx.get_text().strip()
                split_list = value_str.split(':')
                if (0 <= value_str.find('브랜드')) and (0 < value_str.find(':')):
                    product_data.crw_brand1 = split_list[1].strip()
                elif (0 <= value_str.find('판매가')) and (0 <
                                                       value_str.find(':')):
                    sub_split_list = split_list[1].split('(')
                    product_data.crw_price_sale = int(
                        __UTIL__.get_only_digit(sub_split_list[0].strip()))

            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
예제 #9
0
    def set_product_data(self, page_url, soup, product_ctx):

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

            self.reset_product_category(product_data)

            location_ctx = soup.find('div', {'id': 'navigation-bar'})
            if (location_ctx != None):
                span_list = location_ctx.find_all('span')
                idx = 0
                for span_ctx in span_list:
                    idx += 1
                    if (idx == 2):
                        product_data.crw_category1 = span_ctx.get_text().strip(
                        )
                    elif (idx == 3):
                        product_data.crw_category2 = span_ctx.get_text().strip(
                        )
                    elif (idx == 4):
                        product_data.crw_category3 = span_ctx.get_text().strip(
                        )

            ####################################
            # 브랜드 추출
            ####################################

            product_data.crw_brand1 = product_data.crw_category1

            ####################################
            # 상품 이미지 확인
            #
            # <img class="item-image" src="/_vir0001/product_img/P1449_20200421AM94623_2.jpg" alt="img1">
            ####################################

            img_list = product_ctx.find_all('img', class_='item-image')
            for img_ctx in img_list:
                img_src = ''
                if ('data-original' in img_ctx.attrs):
                    img_src = img_ctx.attrs['data-original'].strip()
                elif ('src' in img_ctx.attrs):
                    img_src = img_ctx.attrs['src'].strip()

                if (img_src != ''):
                    img_link = self.set_img_url(self.BASIC_IMAGE_URL, img_src)
                    product_data.product_img = self.get_hangul_url_convert(
                        img_link)

            ####################################
            # 상품 링크 정보 및 상품코드
            #
            # <div class="item" style="cursor:pointer" onclick="goHref(1449,'P1449_20200421AM94623_2.jpg')">
            ####################################

            if ('onclick' in product_ctx.attrs):
                onclick_str = product_ctx.attrs['onclick'].strip()
                split_data = onclick_str.split('goHref(')
                sub_split_data = split_data[1].split(',')
                product_data.crw_goods_code = sub_split_data[0].strip()
                crw_post_url = 'http://www.montraum.com/common/process/shopview.asp?thisCategory=22&pack_content_id=' + product_data.crw_goods_code

            ####################################
            # 상품명 / 품절여부
            #
            # <p class="item-description" id="iconID1449" name="iconID1449">데일리관리 세트<br> (돈모 브러쉬+플러쉬 콤)</p>
            #
            # ---------- 품절시 -----------------------
            # <p class="item-description" id="iconID1095" name="iconID1095">트레이닝패드 L 120매 (30매 x 4개)<img src="/_vir0001/process/partImages/icon_soldout.gif" align="absmiddle">&nbsp;<img src="/_vir0001/process/partImages/icon_soldout.gif" align="absmiddle">&nbsp;<img src="/_vir0001/process/partImages/icon_soldout.gif" align="absmiddle">&nbsp;<img src="/_vir0001/process/partImages/icon_soldout.gif" align="absmiddle">&nbsp;</p>
            ####################################
            name_div_list = product_ctx.find_all('p',
                                                 class_='item-description')
            for name_div_ctx in name_div_list:
                product_data.crw_name = name_div_ctx.get_text().replace(
                    '\n', ' ').strip()

                # 품절여부
                soldout_img_list = name_div_ctx.find_all('img')
                for soldout_img in soldout_img_list:
                    if ('src' in soldout_img.attrs):
                        if (0 <= soldout_img.attrs['src'].find('soldout')):
                            product_data.crw_is_soldout = 1

            ####################################
            # 가격
            #
            # <p class="item-price">
            # <span class="list-price" id="ori_count1449" name="ori_count1449">74,000</span> <span class="now-price" id="promotion_ID1449" name="promotion_ID1449">40,900</span>
            # </p>
            ####################################

            div_list = product_ctx.find_all('p', class_='item-price')
            for div_ctx in div_list:
                span_list = div_ctx.find_all('span')
                for span_ctx in span_list:
                    if ('class' in span_ctx.attrs):
                        class_name_list = span_ctx.attrs['class']

                        if (class_name_list[0] == 'list-price'):
                            product_data.crw_price = int(
                                __UTIL__.get_only_digit(
                                    span_ctx.get_text().strip()))
                        elif (class_name_list[0] == 'now-price'):
                            product_data.crw_price_sale = int(
                                __UTIL__.get_only_digit(
                                    span_ctx.get_text().strip()))

            if (crw_post_url != ''):
                #if( self.PRODUCT_URL_HASH.get( crw_post_url , -1) == -1) :

                self.set_product_data_sub(product_data, crw_post_url)
                self.process_product_api(product_data)

                rtn = True

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

        return True
예제 #10
0
    def set_product_data(self, page_url, soup, product_ctx):

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

            ####################################
            # 상품 이미지 확인
            # 상품 링크 정보 및 상품코드
            # 카테고리
            #
            # <div class="thumb">
            # <div class="over_view  -mos01">
            # <ul>
            # <li><a href="javascript:viewdetail('011000000054', '1', '');" aria-label="확대보기" class="hint--top"><i class="xi-search" alt="확대보기"></i></a></li>
            # <li><a href="javascript:viewdetail('011000000054', '1', '');" aria-label="관심상품" class="hint--top"><i class="xi-heart-o" alt="관심상품"></i></a></li>
            # <li><a href="/shop/shopdetail.html?branduid=2243605&amp;xcode=009&amp;mcode=000&amp;scode=&amp;type=P&amp;sort=regdate&amp;cur_code=009&amp;GfDT=bm1%2BW1w%3D" aria-label="상세보기" class="hint--top"><i class="xi-bars" alt="상세보기"></i></a></li>
            # </ul>
            # </div>
            # <a href="/shop/shopdetail.html?branduid=2243605&amp;xcode=009&amp;mcode=000&amp;scode=&amp;type=P&amp;sort=regdate&amp;cur_code=009&amp;GfDT=bm1%2BW1w%3D"><img class="MS_prod_img_s" src="/shopimages/coates1024/0110000000543.gif?1581155993"></a>
            # </div>
            ####################################

            img_div_list = product_ctx.find_all('div', class_='thumb')
            for img_div_ctx in img_div_list:
                product_link_list = img_div_ctx.find_all('a')
                img_list = img_div_ctx.find_all('img')
                for img_ctx in img_list:
                    img_src = ''
                    if ('src' in img_ctx.attrs):
                        split_list = img_ctx.attrs['src'].strip().split('?')
                        img_src = split_list[0].strip()

                    if (img_src != ''):
                        img_link = self.set_img_url(self.BASIC_IMAGE_URL,
                                                    img_src)
                        product_data.product_img = self.get_hangul_url_convert(
                            img_link)
                        break

                for product_link_ctx in product_link_list:
                    if ('href' in product_link_ctx.attrs):
                        crw_post_url = self.get_crw_post_url(
                            product_link_ctx, 'href')
                        if (crw_post_url != ''):
                            self.get_crw_goods_code(product_data, crw_post_url)
                            self.get_category_value(product_data, crw_post_url)
                            break

            ####################################
            # 상품명 및 브랜드
            # <li class="name">스카이 브라운 클래식 카시트</li>
            ####################################
            name_strong_list = product_ctx.find_all('li', class_='name')
            for name_strong_ctx in name_strong_list:
                product_data.crw_name = name_strong_ctx.get_text().strip()
                #
                # 이름 앞에 브랜드명이 있음.
                # [스텔라&츄이] 츄이스 치킨 디너패티
                if (0 == product_data.crw_name.find('[')):
                    brand_list = product_data.crw_name.split(']')
                    product_data.crw_brand1 = brand_list[0][1:].strip()

            ####################################
            # 가격 / 품절 여부 확인
            #
            #
            # <li>
            # <div class="over_sale -mos">30%</div>
            # <span class="price01">39,500원</span>
            # <span class="price02">27,600원</span>
            # </li>
            #
            #
            ####################################

            div_list = product_ctx.find_all('ul')
            for div_ctx in div_list:
                sell_ctx = div_ctx.find('span', class_='price02')
                consumer_ctx = div_ctx.find('span', class_='price01')
                soldout_ctx = div_ctx.find('li', class_='soldout')
                if (soldout_ctx != None): product_data.crw_is_soldout = 1

                if (consumer_ctx != None):
                    product_data.crw_price = int(
                        __UTIL__.get_only_digit(
                            consumer_ctx.get_text().strip()))

                if (sell_ctx != None):
                    product_data.crw_price_sale = int(
                        __UTIL__.get_only_digit(sell_ctx.get_text().strip()))

            if (crw_post_url != ''):
                #if( self.PRODUCT_URL_HASH.get( crw_post_url , -1) == -1) :

                self.set_product_data_sub(product_data, crw_post_url)

                self.process_product_api(product_data)

                rtn = True

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

        return True
예제 #11
0
	def set_product_data(self , page_url, soup, product_ctx ) :
		
		# 
		#
		try :
			product_data = ProductData()
			crw_post_url = ''
			
			# 상품 카테고리

			product_data.crw_category1 = self.PAGE_URL_HASH[page_url].replace('()','').strip()
			
			
			###########################
			# 상품 이미지 확인
			#
			# <div class="thumbnail">
			# <a href="/product/detail.html?product_no=123&amp;cate_no=62&amp;display_group=1" name="anchorBoxName_123">
			# <img alt="애견 수제 간식 영양식 호박죽 24개입" id="eListPrdImage123_1" src="//drmypet.co.kr/web/product/medium/202011/5a4fc67ece613964f059f2b053a320df.jpg"/>
			###########################
			self.set_product_image_third( product_data, product_ctx )

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

			###########################
			#
			# <div class="name"><a class="" href="/product/detail.html?product_no=123&amp;cate_no=62&amp;display_group=1"><span class="title displaynone"><span style="font-size:12px;color:#555555;">상품명</span> :</span> <span style="font-size:12px;color:#555555;">애견 수제 간식 영양식 호박죽 24개입</span></a></div>
			###########################
			
			crw_post_url = self.set_product_name_url_fourth( product_data, product_ctx , 'p', 'name')
			if(crw_post_url == '') : crw_post_url = self.set_product_name_url_fourth( product_data, product_ctx , 'strong', 'name')
			if(crw_post_url == '') : crw_post_url = self.set_product_name_url_fourth( product_data, product_ctx , 'div', 'name')
			
			
			##############################
			#
			# <li class="xans-record-" rel="판매가">
			# <strong class="title displaynone"><span style="font-size:12px;color:#555555;font-weight:bold;">판매가</span> :</strong> <span style="font-size:12px;color:#555555;font-weight:bold;">48,000원</span><span id="span_product_tax_type_text" style=""> </span></li>
			#
			##############################
			li_list = product_ctx.find_all('li')
			for li_ctx in li_list :
				value_str = li_ctx.get_text().strip()
				split_list = value_str.split(':')
				if( 0 <= value_str.find('브랜드')) and ( 0 < value_str.find(':')) :
					product_data.crw_brand1 = split_list[1].strip()
				elif( 0 <= value_str.find('판매가')) and ( 0 < value_str.find(':')) :
					sub_split_list =  split_list[1].split('(')
					product_data.crw_price_sale = int( __UTIL__.get_only_digit( sub_split_list[0].strip() ))


			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	
예제 #12
0
    def set_product_data(self, page_url, soup, product_ctx):

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

            self.reset_product_category(product_data)

            #__LOG__.Trace( page_url )
            #__LOG__.Trace( self.PAGE_URL_HASH[page_url])

            if (self.C_DETAIL_CATEGORY_VALUE.strip() != ''):
                split_list = self.PAGE_URL_HASH[page_url].split('|')
                idx = 0
                for split_data in split_list:
                    idx += 1
                    if (idx == 1): product_data.crw_category1 = split_data
                    elif (idx == 2): product_data.crw_category2 = split_data
                    elif (idx == 3): product_data.crw_category3 = split_data
            else:
                self.set_godo_category_data(soup, product_data)

            ####################################
            # 브랜드 추출
            #
            # <span class="item_brand">
            # <strong>[지그니쳐]</strong>
            # </span>
            #
            ####################################
            brand_div_list = product_ctx.find_all('span', class_='item_brand')
            for brand_ctx in brand_div_list:
                brand_name = brand_ctx.get_text().strip()
                if (brand_name != ''):
                    product_data.crw_brand1 = brand_name.replace(
                        '[', '').replace(']', '').strip()

            ####################################
            # 상품 이미지 확인
            #
            # <div class="item_photo_box">
            # <a href="../goods/goods_view.php?goodsNo=1000000896&amp;mtn=%5E%7C%5E%5E%7C%5E">
            # <img data-original="/data/goods/19/10/43/1000000896/1000000896_add2_085.jpg" width="250" alt="바잇밀 - 치킨/오리/말고기 샘플러 100g (3종)" title="바잇밀 - 치킨/오리/말고기 샘플러 100g (3종)" class="middle gd_image_lazy" src="/data/goods/19/10/43/1000000896/1000000896_add2_085.jpg" style="display: inline;">
            # </a>
            # </div>
            ####################################
            img_div_list = product_ctx.find_all('div', class_='item_photo_box')
            for img_div_ctx in img_div_list:
                img_ctx = img_div_ctx.find('img')
                #for img_ctx in img_list :

                if (img_ctx != None):
                    img_src = ''
                    if ('data-original' in img_ctx.attrs):
                        img_src = img_ctx.attrs['data-original'].strip()
                    elif ('src' in img_ctx.attrs):
                        img_src = img_ctx.attrs['src'].strip()

                    if (img_src != ''):
                        img_link = self.set_img_url(self.BASIC_IMAGE_URL,
                                                    img_src)
                        if (product_data.product_img == ''):
                            product_data.product_img = self.get_hangul_url_convert(
                                img_link)

            ####################################
            # 품절여부 추출 (2가지 방법)
            #
            # <div class="item_icon_box">
            # <img src="/data/icon/goods_icon/당일출고아이콘.gif" alt="벌써배송상품" title="벌써배송상품" class="middle">
            # <img src="/data/icon/goods_icon/icon_soldout.gif">
            # </div>
            #
            #------------------------------------
            #
            # <div class="item_photo_box">
            # <a href="../goods/goods_view.php?goodsNo=1000001614">
            # <img data-original="/data/goods/20/05/20/1000001614/1000001614_add2_099.jpg" width="250" alt="빅독 리틀 바이트 사료 - 악어고기 100g" title="빅독 리틀 바이트 사료 - 악어고기 100g" class="middle gd_image_lazy" src="/data/goods/20/05/20/1000001614/1000001614_add2_099.jpg" style="display: inline;">
            # <strong class="item_soldout_bg" style="background-image:url(/data/icon/goods_icon/soldout-1.png);">SOLD OUT</strong>
            # </a>
            # </div>
            #
            ####################################
            soldout_div_list = product_ctx.find_all('div',
                                                    class_='item_icon_box')
            for soldout_div_ctx in soldout_div_list:
                img_list = soldout_div_ctx.find_all('img')
                for img_ctx in img_list:
                    if ('src' in img_ctx.attrs):
                        if (0 < img_ctx.attrs['src'].find('soldout')):
                            product_data.crw_is_soldout = 1

            if (product_data.crw_is_soldout != 1):
                soldout_div_list = product_ctx.find_all(
                    'div', class_='item_photo_box')
                for soldout_div_ctx in soldout_div_list:
                    img_list = soldout_div_ctx.find_all(
                        'strong', class_='item_soldout_bg')
                    for img_ctx in img_list:
                        product_data.crw_is_soldout = 1

            ####################################
            # 상품 링크 정보 및 상품명 / 상품코드
            #
            # <div class="item_tit_box">
            # <a href="../goods/goods_view.php?goodsNo=1000001614">
            # <strong class="item_name">빅독 리틀 바이트 사료 - 악어고기 100g</strong>
            # </a>
            # </div>
            #
            ####################################
            name_strong_list = product_ctx.find_all('div',
                                                    class_='item_tit_box')
            for name_strong_ctx in name_strong_list:
                product_link_list = name_strong_ctx.find_all('a')
                for product_link_ctx in product_link_list:

                    if ('href' in product_link_ctx.attrs):
                        span_list = product_link_ctx.find_all('strong')
                        for span_ctx in span_list:
                            product_data.crw_name = span_ctx.get_text().strip()

                        tmp_product_link = product_link_ctx.attrs[
                            'href'].strip()
                        if (0 != tmp_product_link.find('http')):
                            tmp_product_link = '%s%s' % (
                                self.BASIC_PRODUCT_URL,
                                product_link_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('?goodsNo=')
                        product_data.crw_goods_code = split_list[1].strip()

            ####################################
            # 가격
            #
            # <div class="item_money_box">
            # <strong class="item_price">
            # <span>23,000원 </span>
            # </strong>
            # </div>
            #
            ####################################

            div_list = product_ctx.find_all('div', class_='item_money_box')
            for div_ctx in div_list:
                del_ctx = div_ctx.find('del')
                strong_ctx = div_ctx.find('strong', class_='item_price')
                if (del_ctx != None):
                    product_data.crw_price = int(
                        __UTIL__.get_only_digit(del_ctx.get_text().strip()))
                if (strong_ctx != None):
                    # 타임세일일때  뒷부분의 별도의 값이 붙어서, 값 이상 문제 해결법,
                    crw_price_sale = strong_ctx.get_text().strip().split('\n')
                    product_data.crw_price_sale = int(
                        __UTIL__.get_only_digit(crw_price_sale[0].strip()))

            if (crw_post_url != ''):
                #if( self.PRODUCT_URL_HASH.get( crw_post_url , -1) == -1) :

                self.set_product_data_sub(product_data, crw_post_url)
                self.process_product_api(product_data)

                rtn = True

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

        return True
예제 #13
0
    def set_product_data(self, page_url, soup, product_ctx):

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

            ####################################
            # 상품 이미지 확인
            # 상품 링크 정보 및 상품코드
            # 카테고리
            #
            # <dt class="thumb"><a href="/shop/shopdetail.html?branduid=111062&amp;xcode=020&amp;mcode=004&amp;scode=&amp;type=X&amp;sort=regdate&amp;cur_code=020&amp;GfDT=bmx9W1w%3D"><img class="MS_prod_img_m" src="/shopimages/affetto/0200040000052.jpeg?1563325993"></a></dt>
            #
            ####################################

            img_div_list = product_ctx.find_all('dt', class_='thumb')
            for img_div_ctx in img_div_list:
                img_list = img_div_ctx.find_all('img')
                for img_ctx in img_list:
                    img_src = ''
                    if ('src' in img_ctx.attrs):
                        split_list = img_ctx.attrs['src'].strip().split('?')
                        img_src = split_list[0].strip()

                    if (img_src != ''):
                        img_link = self.set_img_url(self.BASIC_IMAGE_URL,
                                                    img_src)
                        product_data.product_img = self.get_hangul_url_convert(
                            img_link)
                        break

                product_link_ctx = img_div_ctx.find('a')
                if (product_link_ctx != None):
                    if ('href' in product_link_ctx.attrs):
                        crw_post_url = self.get_crw_post_url(
                            product_link_ctx, 'href')
                        if (crw_post_url != ''):
                            self.get_crw_goods_code(product_data, crw_post_url)
                            self.get_category_value(product_data, crw_post_url)

            ####################################
            # 상품명 및 브랜드
            #
            # <li class="prd-name"><a href="/shop/shopdetail.html?branduid=111062&amp;xcode=020&amp;mcode=004&amp;scode=&amp;type=X&amp;sort=regdate&amp;cur_code=020&amp;GfDT=bmx9W1w%3D">이글루 하우스 - M / L</a></li>
            ####################################
            name_dd_list = product_ctx.find_all('dd', class_='prd-info')
            for name_dd_ctx in name_dd_list:
                name_ctx = name_dd_ctx.find('li', class_='prd-name')
                if (name_ctx != None):
                    product_data.crw_name = name_ctx.get_text().strip()

                brand_ctx = name_dd_ctx.find('li', class_='prd-brand')
                if (brand_ctx != None):
                    product_data.crw_brand1 = brand_ctx.get_text().strip()

            ####################################
            # 가격 / 품절 여부 확인
            #
            #
            # <li class="prd-price">
            # <strike>95,000원</strike>
            # <span class="price">85,500원</span>
            # </li>
            #
            # ---- 품절시 ----
            # <li class="prd-price">
            # Sold Out
            # </li>
            ####################################

            div_list = product_ctx.find_all('li', class_='prd-price')
            for div_ctx in div_list:
                sell_ctx = div_ctx.find('span', class_='price')
                consumer_ctx = div_ctx.find('strike')

                soldout_str = div_ctx.get_text().strip()
                if (0 < soldout_str.find('Out')):
                    product_data.crw_is_soldout = 1

                if (consumer_ctx != None):
                    product_data.crw_price = int(
                        __UTIL__.get_only_digit(
                            consumer_ctx.get_text().strip()))

                if (sell_ctx != None):
                    product_data.crw_price_sale = int(
                        __UTIL__.get_only_digit(sell_ctx.get_text().strip()))

            if (crw_post_url != ''):
                #if( self.PRODUCT_URL_HASH.get( crw_post_url , -1) == -1) :

                self.set_product_data_sub(product_data, crw_post_url)
                self.process_product_api(product_data)

                rtn = True

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

        return True
예제 #14
0
	def set_product_data(self , page_url, soup, product_ctx ) :
		
		# 
		#
		try :
			product_data = ProductData()
			crw_post_url = ''
			
			self.reset_product_category(product_data)
			
			self.get_category_value( product_data, page_url, soup )
	
					
			####################################
			# 브랜드 추출	
			#
			# <div class="brand">SALLYS LAW</div>
			####################################
			brand_div_list = product_ctx.find_all('div', class_='brand')
			for brand_ctx in brand_div_list :
				product_data.crw_brand1 = brand_ctx.get_text().strip()
				
			####################################				
			# 상품 이미지 확인
			#
			# <div class="img">
			# <img src="//image.wconcept.co.kr/productimg/image/img1/96/300972496.jpg?RS=300" alt="">
			# </div>
			####################################
			img_div_list = product_ctx.find_all('div', class_='img')
			for img_div_ctx in img_div_list :
				img_list = img_div_ctx.find_all('img')
				for img_ctx in img_list :
					img_src = ''
					if('data-original' in img_ctx.attrs ) : img_src = img_ctx.attrs['data-original'].strip()
					elif('src' in img_ctx.attrs ) : img_src = img_ctx.attrs['src'].strip()
					
					split_list = img_src.split('?')
					img_src = split_list[0].strip()
					if( img_src != '' ) :
						img_link = self.set_img_url( self.BASIC_IMAGE_URL, img_src )
						product_data.product_img = self.get_hangul_url_convert( img_link )

			'''				
			####################################
			# 품절여부 추출
			####################################
			soldout_div_list = product_ctx.find_all('div', class_='item_icon_box')
			for soldout_div_ctx in soldout_div_list :
				img_list = soldout_div_ctx.find_all('img')
				for img_ctx in img_list :
					if('src' in img_ctx.attrs ) :
						if(0 < img_ctx.attrs['src'].find('soldout') ) : product_data.crw_is_soldout = 1

			'''

			
			####################################
			# 상품 링크 정보 및 상품명 / 상품코드
			#
			# <a href="/Product/300972496">
			# 
			####################################
			

			product_link_ctx = product_ctx.find('a')
			if( product_link_ctx != None ) :

				if('href' in product_link_ctx.attrs ) : 
					tmp_product_link = product_link_ctx.attrs['href'].strip()
					if(0 != tmp_product_link.find('http')) : tmp_product_link = '%s%s' % ( self.BASIC_PRODUCT_URL, product_link_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_data.crw_goods_code = split_list[4].strip()
					
				
			name_strong_list = product_ctx.find_all('div', class_='product ellipsis multiline')
			for name_strong_ctx in name_strong_list :
				product_data.crw_name = name_strong_ctx.get_text().strip()

			
			
			####################################
			# 가격
			#
			# <div class="price">
			# <span class="discount_price">74,400</span>
			# <span class="base_price">93,000</span>
			# <span class="discount_rate">20%</span>
			# </div>
			#
			####################################
			
			div_list = product_ctx.find_all('div', class_='price')
			for div_ctx in div_list :
				span_list = div_ctx.find_all('span')
				for span_ctx in span_list :
					if('class' in span_ctx.attrs ) :
						class_name_list = span_ctx.attrs['class']
						if(class_name_list[0] == 'base_price' ) : product_data.crw_price = int( __UTIL__.get_only_digit( span_ctx.get_text().strip() ) )
						elif(class_name_list[0] == 'discount_price' ) : product_data.crw_price_sale = int( __UTIL__.get_only_digit( span_ctx.get_text().strip() ))
					
			
			if( crw_post_url != '' ) :
				#if( self.PRODUCT_URL_HASH.get( crw_post_url , -1) == -1) : 
				
				self.set_product_data_sub( product_data, crw_post_url )		
				self.process_product_api(product_data)
										
				rtn = True


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

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

            self.reset_product_category(product_data)
            category_ctx_list = soup.select('#menu_inner')
            for category_ctx in category_ctx_list:
                split_list = category_ctx.get_text().strip().split('>')
                idx = 0
                for a_ctx in split_list:
                    idx += 1
                    category_name = a_ctx.strip()
                    if (idx == 2): product_data.crw_category1 = category_name
                    elif (idx == 3): product_data.crw_category2 = category_name
                    elif (idx == 4): product_data.crw_category3 = category_name

            #product_data.crw_category1 = self.PAGE_URL_HASH[page_url]

            ############################
            # 품절여부
            ############################
            soldout_ctx = product_ctx.find('span', class_='soldOut')
            if (soldout_ctx != None): product_data.crw_is_soldout = 1

            ####################################
            # 상품 이미지 확인
            #
            # <div class="thumbnail">
            # <div class="centered">
            # <a href="prd_detail.php?idx=171&amp;part_idx=90"><img src="/data/goodsImages/1529056838_IMAGES1.jpg" data-pin-nopin="true"></a>
            # </div>
            # </div>
            ####################################

            span_list = product_ctx.find_all('div', class_='thumbnail')
            for span_ctx in span_list:
                product_link_ctx = span_ctx.find('a')
                if (product_link_ctx != None):
                    img_list = product_link_ctx.find_all('img')
                    for img_ctx in img_list:
                        img_src = ''
                        if ('data-original' in img_ctx.attrs):
                            img_src = img_ctx.attrs['data-original'].strip()
                        elif ('src' in img_ctx.attrs):
                            img_src = img_ctx.attrs['src'].strip()

                        if (img_src != ''):
                            img_link = self.set_img_url(
                                self.BASIC_IMAGE_URL, img_src)
                            product_data.product_img = self.get_hangul_url_convert(
                                img_link)

            ####################################
            # 상품명 / 상품 링크 정보 / 상품번호
            #
            # <div class="title"><a href="prd_detail.php?idx=171&amp;part_idx=90"><!--[보듬]--> 보듬 10mm 폴딩 리드줄 (길이 조절 가능)</a></div>
            ####################################
            name_div_list = product_ctx.find_all('div', class_='title')
            for name_div_ctx in name_div_list:
                span_ctx = name_div_ctx.find('a')
                if (span_ctx != None):
                    if ('href' in span_ctx.attrs):
                        tmp_product_link = span_ctx.attrs['href'].strip()
                        if (0 != tmp_product_link.find('http')):
                            tmp_product_link = '%s%s' % (
                                self.BASIC_PRODUCT_URL,
                                span_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('?idx=')
                        sub_split_list = split_list[1].strip().split('&')
                        product_data.crw_goods_code = sub_split_list[0]

                    split_list = span_ctx.get_text().strip().split(']')
                    crw_name = split_list[0].strip()
                    if (len(split_list) == 2):
                        product_data.crw_brand1 = split_list[0].replace(
                            '[', '').strip()
                        crw_name = split_list[1].strip()
                    product_data.crw_name = crw_name

            ####################################
            # 가격
            #
            # <div class="priceWrap">
            # <div class="saleprice"><span>119,000</span>원</div>
            # <div class="price"><strong>101,150</strong>원</div>
            # </div>
            ####################################

            div_list = product_ctx.find_all('div', class_='priceWrap')
            for div_ctx in div_list:
                saleprice_ctx = div_ctx.find('div', class_='saleprice')
                price_ctx = div_ctx.find('div', class_='price')
                if (saleprice_ctx != None):
                    product_data.crw_price = int(
                        __UTIL__.get_only_digit(
                            saleprice_ctx.get_text().strip()))
                if (price_ctx != None):
                    product_data.crw_price_sale = int(
                        __UTIL__.get_only_digit(price_ctx.get_text().strip()))

            if (crw_post_url != ''):
                #if( self.PRODUCT_URL_HASH.get( crw_post_url , -1) == -1) :

                self.set_product_data_sub(product_data, crw_post_url)
                self.process_product_api(product_data)

                rtn = True

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

        return True
예제 #16
0
    def set_product_data(self, page_url, soup, product_ctx):

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

            ####################################
            # 상품 이미지 확인
            # 상품 링크 정보 및 상품코드
            # 카테고리
            #
            # <dd class="prd-img"><img class="MS_prod_img_s" src="/shopimages/ecofoam/0450010000053.jpg?1527467204" alt="상품 섬네일" title="상품 섬네일"></dd>
            #
            #
            # <dl class="item grid-item opa70" style="position: absolute; left: 0px; top: 0px;">
            #<a href="/shop/shopdetail.html?branduid=841206&amp;xcode=046&amp;mcode=004&amp;scode=&amp;type=Y&amp;sort=manual&amp;cur_code=046&amp;GfDT=bW53UQ%3D%3D">
            #
            #
            ####################################

            img_div_list = product_ctx.find_all('dd', class_='prd-img')
            for img_div_ctx in img_div_list:
                img_list = img_div_ctx.find_all('img')
                for img_ctx in img_list:
                    img_src = ''
                    if ('src' in img_ctx.attrs):
                        split_list = img_ctx.attrs['src'].strip().split('?')
                        img_src = split_list[0].strip()

                    if (img_src != ''):
                        img_link = self.set_img_url(self.BASIC_IMAGE_URL,
                                                    img_src)
                        product_data.product_img = self.get_hangul_url_convert(
                            img_link)
                        break

            product_link_ctx = product_ctx.find('a')
            if (product_link_ctx != None):
                if ('href' in product_link_ctx.attrs):
                    crw_post_url = self.get_crw_post_url(
                        product_link_ctx, 'href')
                    if (crw_post_url != ''):
                        self.get_crw_goods_code(product_data, crw_post_url)
                        self.get_category_value(product_data, crw_post_url)

            ####################################
            # 상품명 및 브랜드
            #
            # <span class="prd-name ft_eb">도그자리 플랫<br></span>
            #
            # --- 품절시 상품명 ---
            # <span class="prd-name ft_eb">맘편한매트 소프트W<br>8세트(품절)</span>
            #
            # --- 브랜드 ---
            # <span class="prd-brand">도그자리</span>
            ####################################

            name_strong_ctx = product_ctx.find('span', class_='prd-name ft_eb')
            if (name_strong_ctx != None):
                crw_name = name_strong_ctx.get_text().strip()
                if (0 < crw_name.find('(품절)')):
                    product_data.crw_is_soldout = 1
                    tmp_crw_name = crw_name.replace('(품절)', '').strip()
                    crw_name = tmp_crw_name

                product_data.crw_name = crw_name

            name_strong_ctx = product_ctx.find('span', class_='prd-brand')
            if (name_strong_ctx != None):
                product_data.crw_brand1 = name_strong_ctx.get_text().strip()

            ####################################
            # 가격
            #
            # <span class="prd-price-discount"><del>75,000</del></span>
            #
            # <span class="prd-discount ft_eb">52,000&nbsp;원</span>
            #
            ####################################

            div_list = product_ctx.find_all('div', class_='prd-sub')
            for div_ctx in div_list:
                sell_ctx = div_ctx.find('span', class_='prd-discount ft_eb')
                consumer_ctx = div_ctx.find('span',
                                            class_='prd-price-discount')

                if (consumer_ctx != None):
                    product_data.crw_price = int(
                        __UTIL__.get_only_digit(
                            consumer_ctx.get_text().strip()))

                if (sell_ctx != None):
                    product_data.crw_price_sale = int(
                        __UTIL__.get_only_digit(sell_ctx.get_text().strip()))

            if (crw_post_url != ''):
                #if( self.PRODUCT_URL_HASH.get( crw_post_url , -1) == -1) :

                self.set_product_data_sub(product_data, crw_post_url)
                self.process_product_api(product_data)

                rtn = True

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

        return True
예제 #17
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	
예제 #18
0
	def set_product_data(self , page_url, soup, product_ctx ) :
		
		# 
		#
		try :
			product_data = ProductData()
			crw_post_url = ''
			
			####################################				
			# 상품 이미지 확인
			# 상품 링크 정보 및 상품코드
			# 카테고리
			#
			# <dt class="thumb"><a href="/shop/shopdetail.html?branduid=10163894&amp;xcode=001&amp;mcode=005&amp;scode=003&amp;type=X&amp;sort=manual&amp;cur_code=001&amp;GfDT=bml9W1w%3D"><img class="MS_prod_img_m" src="/shopimages/dermadog/0010050000192.jpg?1591754112" alt="상품 섬네일" title="상품 섬네일"></a></dt>
			####################################

			img_div_list = product_ctx.find_all('dt', class_='thumb')
			for img_div_ctx in img_div_list :
				img_list = img_div_ctx.find_all('img')
				for img_ctx in img_list :
					img_src = ''
					if('src' in img_ctx.attrs ) : 
						split_list = img_ctx.attrs['src'].strip().split('?')
						img_src = split_list[0].strip()
						
					if( img_src != '' ) :
						img_link = self.set_img_url( self.BASIC_IMAGE_URL, img_src )
						product_data.product_img = self.get_hangul_url_convert( img_link )
						break

				product_link_ctx = img_div_ctx.find('a')
				if( product_link_ctx != None) :
					if('href' in product_link_ctx.attrs ) : 
						crw_post_url = self.get_crw_post_url( product_link_ctx, 'href')
						if(crw_post_url != '') :
							self.get_crw_goods_code( product_data, crw_post_url )
							self.get_category_value( product_data, crw_post_url )
						

			
			####################################
			# 상품명 및 브랜드
			#
			# <dd class="prd-info">
			# <ul>  
			# <li class="prd-brand"><span class="MK-product-icons"><img src="/shopimages/dermadog/prod_icons/4154?1591753540" class="MK-product-icon-2"></span></li>
			# <li class="prd-name"><a href="/shop/shopdetail.html?branduid=10163894&amp;xcode=001&amp;mcode=005&amp;scode=003&amp;type=X&amp;sort=manual&amp;cur_code=001&amp;GfDT=bml9W1w%3D">연어/스킨 헬스츄 15g</a></li>
			# </ul>
			# </dd>
			#
			####################################
			name_dd_list = product_ctx.find_all('dd', class_='prd-info')
			for name_dd_ctx in name_dd_list :
				name_ctx = name_dd_ctx.find('li', class_='prd-name')
				if( name_ctx != None) : product_data.crw_name = name_ctx.get_text().strip()
				
				brand_ctx = name_dd_ctx.find('li', class_='prd-brand')
				if( brand_ctx != None) : product_data.crw_brand1 = brand_ctx.get_text().strip()


			####################################
			# 가격 / 품절 여부 확인
			#
			#
			# <p class="price-info">
			# <strike>10,000</strike><br>
			# <span class="won">₩</span><span class="price">9,000</span>
			# </p>
			#
			#---- 품절시  -------
			#
			# <p class="price-info">
			# Sold Out
			# </p>
			#
			####################################
			
			div_list = product_ctx.find_all('p', class_='price-info')
			for div_ctx in div_list :
				price_str = div_ctx.get_text().strip()
				if(0 <= price_str.find('Out')) : product_data.crw_is_soldout = 1
				
				sell_ctx = div_ctx.find('span', class_='price')
				consumer_ctx = div_ctx.find('strike')
					
				if( consumer_ctx != None ) : product_data.crw_price = int( __UTIL__.get_only_digit( consumer_ctx.get_text().strip() ))

				if( sell_ctx != None ) : product_data.crw_price_sale = int( __UTIL__.get_only_digit( sell_ctx.get_text().strip() ))
			

			if( crw_post_url != '' ) :
				#if( self.PRODUCT_URL_HASH.get( crw_post_url , -1) == -1) : 
				
				self.set_product_data_sub( product_data, crw_post_url )			
				self.process_product_api(product_data)
										
				rtn = True


		except Exception as ex:
			__LOG__.Error('에러 : set_product_data')
			__LOG__.Error(ex)
			pass
			
		return True	
예제 #19
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)

            # 상품 이미지 확인
            # <a href="/product/detail.html?product_no=417&amp;cate_no=29&amp;display_group=1" name="anchorBoxName_417"><img src="//www.wefam.co.kr/web/product/medium/201704/417_shop1_670038.jpg?cmd=thumb&amp;width=300&amp;height=300" data-original="//www.wefam.co.kr/web/product/medium/201704/417_shop1_670038.jpg?cmd=thumb&amp;width=300&amp;height=300" id="eListPrdImage417_1" alt="" class="thumb" style="display: inline; opacity: 1;"></a>
            ###########################
            img_link_list = product_ctx.find_all('a')
            for img_link_ctx in img_link_list:
                if ('name' in img_link_ctx.attrs):
                    if (0 <=
                            img_link_ctx.attrs['name'].find('anchorBoxName_')):
                        tmp_product_link = img_link_ctx.attrs['href'].strip()

                        if (0 != tmp_product_link.find('http')):
                            tmp_product_link = '%s%s' % (
                                self.BASIC_PRODUCT_URL,
                                img_link_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()

                        img_ctx = img_link_ctx.find('img')
                        if (img_ctx != None):
                            if ('data-original' in img_ctx.attrs):
                                img_src = img_ctx.attrs['data-original'].strip(
                                )
                                if (img_src != ''):
                                    img_link = self.set_img_url(
                                        self.BASIC_IMAGE_URL, img_src)
                                    if (product_data.product_img == ''):
                                        product_data.product_img = self.get_hangul_url_convert(
                                            img_link)

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

            #
            # 상품명 / 가격
            #
            # <ul class="xans-product-listitem">
            # <li class="manu">we.fam (위팸)</li>
            # <li class="second"><span><span style="font-size:13px;color:#2e2e2e;">Zigzag Pattern Sleeveless_Navy</span></span></li>
            # <li class="custom">25,000 WON</li>
            # <li class="price">15,800 WON</li>
            # </ul>
            #
            li_list = product_ctx.find_all('li')

            for li_ctx in li_list:
                if ('class' in li_ctx.attrs):
                    class_name_list = li_ctx.attrs['class']
                    value_str = li_ctx.get_text().strip()
                    if (class_name_list[0] == 'manu'):
                        product_data.crw_brand1 = value_str
                    elif (class_name_list[0] == 'second'):
                        product_data.crw_name = value_str
                    elif (class_name_list[0] == 'custom'):
                        int_value_str = int(__UTIL__.get_only_digit(value_str))
                        if (int_value_str != 0):
                            product_data.crw_price = int(
                                __UTIL__.get_only_digit(value_str))
                    elif (class_name_list[0] == 'price'):
                        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
예제 #20
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
예제 #21
0
    def set_product_data(self, page_url, soup, product_ctx):

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

            ####################################
            # 상품 이미지 확인
            # 상품 링크 정보 및 상품코드
            # 카테고리
            #
            # <div class="thumb salebox">
            # <a href="/shop/shopdetail.html?branduid=3534594&amp;xcode=003&amp;mcode=001&amp;scode=&amp;type=X&amp;sort=manual&amp;cur_code=003&amp;GfDT=aWt3UQ%3D%3D"><img class="MS_prod_img_m" src="/shopimages/cocochien/0030010000152.jpg?1581790516" alt="상품 섬네일"></a>
            # <input type="hidden" name="custom_price" value="0">
            # <input type="hidden" name="product_price" value="34500">
            # <div id="sale_bg" style="display: none;"><span class="sale_text"></span></div>
            # <div class="info_icon">
            # <span class="m_quickview"><a class="btn-overlay-show" href="javascript:viewdetail('003001000015', '1', '');"><img src="/design/cocochien/0746amelie/info_icon02.gif"></a></span>										<span class="m_option"><img src="/shopimages/cocochien/bt_opt_preview.gif" onclick="javascript:mk_prd_option_preview('3534594',event);"></span>									</div><!-- //info_icon -->
            # </div>
            ####################################

            img_div_list = product_ctx.find_all('div', class_='thumb salebox')
            for img_div_ctx in img_div_list:
                product_link_list = img_div_ctx.find_all('a')
                img_list = img_div_ctx.find_all('img')
                for img_ctx in img_list:
                    img_src = ''
                    if ('src' in img_ctx.attrs):
                        split_list = img_ctx.attrs['src'].strip().split('?')
                        img_src = split_list[0].strip()

                    if (img_src != ''):
                        img_link = self.set_img_url(self.BASIC_IMAGE_URL,
                                                    img_src)
                        product_data.product_img = self.get_hangul_url_convert(
                            img_link)
                        break

                for product_link_ctx in product_link_list:
                    if ('href' in product_link_ctx.attrs):
                        crw_post_url = self.get_crw_post_url(
                            product_link_ctx, 'href')
                        if (crw_post_url != ''):
                            self.get_crw_goods_code(product_data, crw_post_url)
                            self.get_category_value(product_data, crw_post_url)
                            break

            ####################################
            # 상품명 및 브랜드
            # <li class="dsc">앨리스튜튜</li>
            ####################################
            name_strong_list = product_ctx.find_all('li', class_='dsc')
            for name_strong_ctx in name_strong_list:
                product_data.crw_name = name_strong_ctx.get_text().strip()
                #
                # 이름 앞에 브랜드명이 있음.
                # [스텔라&츄이] 츄이스 치킨 디너패티
                if (0 == product_data.crw_name.find('[')):
                    brand_list = product_data.crw_name.split(']')
                    product_data.crw_brand1 = brand_list[0][1:].strip()

            ####################################
            # 가격 / 품절 여부 확인
            #
            #<ul class="info">
            # <li class="dsc">네이비도트원피스(50%SALE)SM,XL주문가능</li>
            # <li class="subname"></li>
            # <li class="consumer">26,000원</li>										<li class="price">13,000원</li>
            # <li class="icon"><span class="MK-product-icons"></span></li>
            # </ul>
            #
            #---------- 품절시 --------------------
            # <ul class="info">
            #	<li class="dsc">마카롱나시원피스(50%SALE)</li>
            #	<li class="subname"></li>
            #	<li class="soldout">SOLD OUT</li>
            #	<li class="icon"><span class="MK-product-icons"></span></li>
            #	</ul>
            ####################################

            div_list = product_ctx.find_all('ul')
            for div_ctx in div_list:
                sell_ctx = div_ctx.find('li', class_='price')
                consumer_ctx = div_ctx.find('li', class_='consumer')
                soldout_ctx = div_ctx.find('li', class_='soldout')
                if (soldout_ctx != None): product_data.crw_is_soldout = 1

                if (consumer_ctx != None):
                    product_data.crw_price = int(
                        __UTIL__.get_only_digit(
                            consumer_ctx.get_text().strip()))

                if (sell_ctx != None):
                    product_data.crw_price_sale = int(
                        __UTIL__.get_only_digit(sell_ctx.get_text().strip()))

            if (crw_post_url != ''):
                #if( self.PRODUCT_URL_HASH.get( crw_post_url , -1) == -1) :

                self.set_product_data_sub(product_data, crw_post_url)
                self.process_product_api(product_data)

                rtn = True

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

        return True
예제 #22
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_first(product_data, product_ctx )
	

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

			name_div_list = product_ctx.find_all('div', class_='sp-product__title')
			
			for name_div_ctx in name_div_list :
				
				product_link_list = name_div_ctx.find_all('a')
				for product_link_ctx in product_link_list :

					if('href' in product_link_ctx.attrs ) : 
						span_list = product_link_ctx.find_all('span')
						for span_ctx in span_list :
							name_value = span_ctx.get_text().strip()
							
							if(0 != name_value.find('상품명') ) and (0 != name_value.find(':') ) : product_data.crw_name = name_value
							
						tmp_product_link = product_link_ctx.attrs['href'].strip()
						if(0 != tmp_product_link.find('http')) : tmp_product_link = '%s%s' % ( self.BASIC_PRODUCT_URL, product_link_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('/')
						if( product_data.crw_name == '') : product_data.crw_name = split_list[4].strip()
						product_data.crw_goods_code = split_list[5].strip()
						

			div_list = product_ctx.find_all('div')
			for div_ctx in div_list :
				if('rel' in div_ctx.attrs) :
					title_name =  div_ctx.attrs['rel']
					span_list = div_ctx.find_all('span')
					for span_ctx in span_list :
						span_value = span_ctx.get_text().strip()
						if(span_value != '브랜드' ) and  (span_value != '판매가' ) and (span_value != '할인가' ) and (span_value != '' ) :
							if(title_name == '판매가') : product_data.crw_price = int( __UTIL__.get_only_digit( span_value ) )
							if(title_name == '할인가') : product_data.crw_price_sale = int( __UTIL__.get_only_digit( span_value ) )
							if(title_name == '브랜드') : product_data.crw_brand1 = span_value
			
			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
예제 #23
0
    def set_product_data(self, category_num, soup, product_ctx):

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

            self.reset_product_category(product_data)

            split_list = self.CATEGORY_URL_HASH[category_num].split('|')
            idx = 0
            for category_name in split_list:
                idx += 1
                if (idx == 1): product_data.crw_category1 = category_name
                elif (idx == 2): product_data.crw_category2 = category_name
                elif (idx == 3): product_data.crw_category3 = category_name

            #product_data.crw_category1 = self.CATEGORY_URL_HASH[category_num]

            ####################################
            # 상품 이미지 확인
            #
            # <div class="saleCard__area-img"><i class="saleCard__badge--new"><svg height="33" viewBox="0 0 33 33" width="33" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><circle cx="16.5" cy="16.5" fill="#3E0A7D" r="16" stroke="#FFF"></circle><path d="M15.38 19.37v-6.71h-1.33v6.71h1.33zm-7.01-1.23c.54-.187.99-.458 1.35-.815.36-.357.647-.768.86-1.235.2.433.475.813.825 1.14.35.327.782.577 1.295.75l.67-1.05a3.308 3.308 0 0 1-.965-.48c-.27-.2-.492-.427-.665-.68a2.796 2.796 0 0 1-.385-.82 3.242 3.242 0 0 1-.125-.89v-.9H9.89v.9c0 .307-.042.612-.125.915-.083.303-.215.59-.395.86A3.183 3.183 0 0 1 7.7 17.09l.67 1.05zm7.24 3.56v-1.05h-5.04v-1.92H9.25v2.97h6.36zm8.57-3.6v-2.22h1.22v-1.09h-1.22v-2.13h-1.32v5.44h1.32zm-6.7-.09c.527-.18.968-.44 1.325-.78s.635-.74.835-1.2c.193.393.458.738.795 1.035a3.49 3.49 0 0 0 1.235.685l.69-1.02a3.426 3.426 0 0 1-.935-.445 2.538 2.538 0 0 1-1.015-1.375c-.08-.267-.12-.54-.12-.82v-.94h-1.34v.83c0 .313-.04.622-.12.925-.08.303-.207.587-.38.85-.173.263-.397.5-.67.71-.273.21-.603.378-.99.505l.69 1.04zm3.69 3.85c.48 0 .912-.04 1.295-.12.383-.08.71-.197.98-.35.27-.153.477-.34.62-.56.143-.22.215-.47.215-.75s-.072-.528-.215-.745a1.774 1.774 0 0 0-.62-.555 3.376 3.376 0 0 0-.98-.35 6.365 6.365 0 0 0-1.295-.12c-.48 0-.913.04-1.3.12-.387.08-.715.197-.985.35-.27.153-.477.338-.62.555a1.32 1.32 0 0 0-.215.745c0 .28.072.53.215.75.143.22.35.407.62.56.27.153.598.27.985.35.387.08.82.12 1.3.12zm0-1.02c-.593 0-1.043-.062-1.35-.185-.307-.123-.46-.315-.46-.575 0-.253.153-.442.46-.565.307-.123.757-.185 1.35-.185.587 0 1.033.062 1.34.185.307.123.46.312.46.565 0 .26-.153.452-.46.575-.307.123-.753.185-1.34.185z" fill="#FFF" fill-rule="nonzero"></path></g></svg></i><div class="saleCard__area-badge"></div><img alt=" 주식캔 no.6 캥거루 200g" class="saleCard__img--no-bg" src="https://cdn.purplesto.re/media/store/sale/main_image/dogzfinefood_dog_B052DF21_thumb01.png"></div>
            ####################################

            span_list = product_ctx.find_all('div',
                                             class_='saleCard__area-img')
            for span_ctx in span_list:
                img_list = span_ctx.find_all('img',
                                             class_='saleCard__img--no-bg')
                if (len(img_list) == 0):
                    img_list = span_ctx.find_all(
                        'img', class_='saleCard__img--concept')
                for img_ctx in img_list:
                    img_src = ''
                    if ('data-original' in img_ctx.attrs):
                        img_src = img_ctx.attrs['data-original'].strip()
                    elif ('src' in img_ctx.attrs):
                        img_src = img_ctx.attrs['src'].strip()

                    if (img_src != ''):
                        img_link = self.set_img_url(self.BASIC_IMAGE_URL,
                                                    img_src)
                        product_data.product_img = self.get_hangul_url_convert(
                            img_link)

            ####################################
            # 품절여부
            #
            # <div class="saleCard__area-price"><p class="saleCard__price--new">Sold Out</p></div>
            ####################################
            name_div_list = product_ctx.find_all('div',
                                                 class_='saleCard__area-price')
            for name_div_ctx in name_div_list:
                soldout_ctx = name_div_ctx.find('p',
                                                class_='saleCard__price--new')
                if (soldout_ctx != None):
                    if (0 <= soldout_ctx.get_text().find('Out')):
                        product_data.crw_is_soldout = 1

            ####################################
            # 상품명 / 상품 링크 정보 / 상품번호 / 브랜드 / 가격
            #
            # <div class="saleCard__area-content"><a class="saleCard__link" href="/products/brands/65/"><p class="saleCard__brand">로투스</p></a> <a class="saleCard__link" href="/products/sales/1500/"><p class="saleCard__title">CAT 오븐베이크 그레인프리 닭고기 4종</p></a><p class="saleCard__area-tag _saleCardTagArea"><a class="saleCard__tag" href="/products/sales/list/?type=hashtag&amp;value=글루텐프리">#글루텐프리</a> <a class="saleCard__tag" href="/products/sales/list/?type=hashtag&amp;value=그레인프리">#그레인프리</a> <a class="saleCard__tag" href="/products/sales/list/?type=hashtag&amp;value=LID사료">#LID사료</a></p><a class="saleCard__link" href="/products/sales/1500/"><div class="saleCard__area-price"><ins class="saleCard__price--new"><span class="saleCard__price--discount">16%</span> 33,000원</ins> <del class="saleCard__price--old">37,000원</del></div><div class="saleCard__area-review"><div class="review-info__wrap"><i class="review-info__icon"><svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><path d="M6 9.95L2.292 12 3 7.658 0 4.584 4.146 3.95 6 0 7.854 3.95 12 4.584 9 7.658 9.708 12z" id="iconStarYellowA"></path></defs><g fill="none" fill-rule="evenodd" transform="translate(2 2)"><mask fill="#fff" id="iconStarYellowB"><use xlink:href="#iconStarYellowA"></use></mask><use fill="#000" fill-rule="nonzero" xlink:href="#iconStarYellowA"></use><path d="M-2 -2H14V14H-2z" fill="#FA0" mask="url(#iconStarYellowB)"></path></g></svg></i> <em class="review-info__score">5.0</em> <span class="review-info__count">상품평 4</span></div></div></a></div>
            ####################################

            name_div_ctx = product_ctx.find('div',
                                            class_='saleCard__area-content')
            if (name_div_ctx != None):
                link_list = name_div_ctx.find_all('a', class_='saleCard__link')
                for link_ctx in link_list:
                    brand_ctx = link_ctx.find('p', class_='saleCard__brand')
                    name_ctx = link_ctx.find('p', class_='saleCard__title')

                    if (brand_ctx != None):
                        product_data.crw_brand1 = brand_ctx.get_text().strip()

                    if (name_ctx != None):
                        product_data.crw_name = name_ctx.get_text().strip()
                        if ('href' in link_ctx.attrs):
                            tmp_product_link = link_ctx.attrs['href'].strip()
                            if (0 != tmp_product_link.find('http')):
                                tmp_product_link = '%s%s' % (
                                    self.BASIC_PRODUCT_URL,
                                    link_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_data.crw_goods_code = split_list[5].strip()

            ####################################
            # 가격
            #
            # <div class="saleCard__area-price"><ins class="saleCard__price--new"><span class="saleCard__price--discount">16%</span> 33,000원</ins> <del class="saleCard__price--old">37,000원</del></div>
            ####################################

            price_list = product_ctx.find_all('div',
                                              class_='saleCard__area-price')
            for price_ctx in price_list:
                ins_ctx = price_ctx.find('ins', class_='saleCard__price--new')
                del_ctx = price_ctx.find('del', class_='saleCard__price--old')
                if (del_ctx != None):
                    product_data.crw_price = int(
                        __UTIL__.get_only_digit(del_ctx.get_text().strip()))
                if (ins_ctx != None):
                    crw_price_sale = ins_ctx.get_text().strip()
                    strip_str = ''
                    strip_ctx = ins_ctx.find(
                        'span', class_='saleCard__price--discount')
                    if (strip_ctx != None):
                        len_strip_str = len(strip_ctx.get_text().strip())
                        product_data.crw_price_sale = int(
                            __UTIL__.get_only_digit(
                                crw_price_sale[len_strip_str:].strip()))
                    else:
                        product_data.crw_price_sale = int(
                            __UTIL__.get_only_digit(crw_price_sale))

            if (crw_post_url != ''):
                #if( self.PRODUCT_URL_HASH.get( crw_post_url , -1) == -1) :
                self.set_product_data_sub(product_data, crw_post_url)
                self.process_product_api(product_data)

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

        return is_loop