Exemplo n.º 1
0
def getOption(obj, dsPrd):
    try:
        arr_option = []
        is_option = fnc.IS_ELEMENT(obj.find("div", {"id": "listOptScroll1"}))

        if is_option == True:
            # 옵션이 있을때
            list_option = obj.find("div", {
                "id": "listOptScroll1"
            }).find_all("dl", {"class": "op_sell"})

            for obj_option in list_option:
                dic_option = {}
                optname = obj_option.find("dt").text.strip()
                optname = optname.replace("(일시품절)", "").strip()
                is_sale = fnc.IS_ELEMENT(obj_option.find("dd").find("del"))

                if is_sale == True:
                    optprice = obj_option.find("dd").find("del").text.strip()
                else:
                    optprice = obj_option.find("span", {
                        "class": "ff_rbt"
                    }).text.strip()

                optprice = optprice.replace("원", "").replace(",", "")
                dic_option["title"] = optname
                dic_option["price"] = optprice

                arr_option.append(dic_option)
                #print(optname +" : "+ optprice)
        else:
            # 옵션이 없을때
            dic_option = {}

            opt = obj.select('.optionBoxList.1st')[0]
            optname = ''
            optprice = ''

            if fnc.IS_ELEMENT(opt.find('', {'class': 'op_name'})) == True:
                optname = opt.select('.op_name')[0].text.strip()
                optname = optname.replace("[일시품절]", "").strip()
            else:
                optname = dsPrd['PRODUCT_NM']
            # end if
            if fnc.IS_ELEMENT(opt.find('', {'class': 'op_pay'})) == True:
                optprice = opt.select('.op_pay')[0].text.strip()
                optprice = optprice.replace("원", "").replace(",", "")
            else:
                optprice = dsPrd['PRICE']
            # end if

            dic_option["title"] = optname
            dic_option["price"] = optprice
            arr_option.append(dic_option)
        #end if

        return arr_option
    #end try
    except Exception as err:
        logger.error("find error : " + str(err))
Exemplo n.º 2
0
def getCategory(obj) :
	try :
		dic_cate = {}

		if fnc.IS_ELEMENT(obj.find('select', {'name':'i_sCategorynmEn1'})) == True :
			obj_option = obj.find('select', {'name':'i_sCategorynmEn1'}).find('option', {'selected':'selected'})
			cate_cd = obj_option.get('value')
			cate_nm = obj_option.text.strip()
			dic_cate['category_cd1'] = cate_cd
			dic_cate['category_nm1'] = cate_nm
		#end if
		if fnc.IS_ELEMENT(obj.find('select', {'name':'i_sCategorynmEn2'})) == True :
			obj_option = obj.find('select', {'name':'i_sCategorynmEn2'}).find('option', {'selected':'selected'})
			cate_cd = obj_option.get('value')
			cate_nm = obj_option.text.strip()
			dic_cate['category_cd2'] = cate_cd
			dic_cate['category_nm2'] = cate_nm
		#end if
		if fnc.IS_ELEMENT(obj.find('select', {'name':'i_sCategorynmEn3'})) == True :
			obj_option = obj.find('select', {'name':'i_sCategorynmEn3'}).find('option', {'selected':'selected'})
			cate_cd = obj_option.get('value')
			cate_nm = obj_option.text.strip()
			dic_cate['category_cd3'] = cate_cd
			dic_cate['category_nm3'] = cate_nm
		#end if
		

		return dic_cate
	except Exception as err :
		logger.error("find error : "+ str(err))
Exemplo n.º 3
0
def getMainImg(obj, dsPrd):
    try:
        list_main_img = obj.find("ul", {"class": "dR_img"}).find_all('li')

        arr_main_img = []
        for ds_img in list_main_img:
            isVod = fnc.IS_ELEMENT(ds_img.find('div',
                                               {'class': 'video_inner'}))

            if isVod == False:
                img_url = ds_img.find('img').get('src')  # 이미지 url추출

                cnt = img_url.rfind("/") + 1  # 파일명 시작위치
                fullfilename = img_url[cnt:]  # 전체파일명
                filename = fullfilename.split(".")[0]  # 파일명
                ext = fullfilename.split(".")[1]  # 확장자

                #fnc.MAKE_FOLDER(con._UPLOAD_DIR +'/'+ dsPrd['v_brandcd'])

                cust_filename = dsPrd['BRAND_CD'] + "/" + fullfilename
                urllib.request.urlretrieve(img_url, con._UPLOAD_DIR + "/" +
                                           cust_filename)  # 다운로드

                arr_main_img.append(cust_filename)
            #end if
        #end for

        return arr_main_img
    #end try
    except Exception as err:
        logger.error("find error : " + str(err))
Exemplo n.º 4
0
def getMainImg(obj, brand_cd) :
	try :
		list_main_img = obj.find("ul", {"class" : "dR_img"}).find_all('li')

		arr_main_img = []
		for ds_img in list_main_img:
			isVod = fnc.IS_ELEMENT(ds_img.find('div', {'class' : 'video_inner'}))
			
			if isVod == False :
				img_url = ds_img.find('img').get('src')		# 이미지 url추출

				fullfilename = fnc.GET_FILENAME_FROM_URL(img_url)			# 전체파일명

				#fnc.MAKE_FOLDER(con._UPLOAD_DIR +'/'+ dsPrd['v_brandcd'])

				cust_filename = brand_cd +"/"+ fullfilename
				urllib.request.urlretrieve(img_url, con._UPLOAD_DIR +"/"+ cust_filename)		# 다운로드

				arr_main_img.append(cust_filename)
			#end if
		#end for

		return arr_main_img
	#end try
	except Exception as err:
		logger.error("find error : "+ str(err))
Exemplo n.º 5
0
req = requests.get(url)
html = req.text

# make soup
soup = BeautifulSoup(html, 'html.parser')

# set variables
dic_main = {}

# 이미지 내려받기
list_main_img = soup.find("ul", {"class": "dR_img"}).find_all('li')

arr_main_img = []
for ds_img in list_main_img:
    isVod = fnc.IS_ELEMENT(ds_img.find('div', {'class': 'video_inner'}))

    if isVod == False:
        img_url = ds_img.find('img').get('src')  # 이미지 url추출

        cnt = img_url.rfind("/") + 1  # 파일명 시작위치
        fullfilename = img_url[cnt:]  # 전체파일명
        filename = fullfilename.split(".")[0]  # 파일명
        ext = fullfilename.split(".")[1]  # 확장자

        #cust_filename = filename +"_"+ str(_NOW_DT.microsecond) +"."+ ext
        cust_filename = brand_cd + "/" + fullfilename
        urllib.request.urlretrieve(img_url, con._UPLOAD_DIR + "/" +
                                   cust_filename)  # 다운로드

        arr_main_img.append(cust_filename)