This commit is contained in:
Envy_PC 2024-07-27 23:03:08 +09:00
parent e8058979be
commit 5c9ec76808
1 changed files with 36 additions and 0 deletions

View File

@ -49,6 +49,42 @@ def modify_option_page2(driver, product_info, translator, login_info):
# 저장 작업 등
save_changes(driver)
def sort_options_by_price(driver, options_info):
for idx in range(1, len(options_info) + 1):
try:
# 옵션 타입별로 낮은가격순 정렬
sort_button_xpath = f"//div[{idx}]/div/div/div[2]/div/div/div[4]/div[2]/div[2]/div/div[4]/button"
click_element(driver, 'XPATH', sort_button_xpath, 10, 'js')
logger.debug(f"옵션 타입 {idx} 낮은 가격순 정렬 완료")
except Exception as e:
logger.error(f"옵션 타입 {idx} 낮은 가격순 정렬 중 오류 발생: {e}", exc_info=True)
def filter_out_bait_items(options_info):
for option_type_key, option_data in options_info.items():
item_prices = []
for item in option_data['option_elements']:
price_css = "div:nth-child(3) > div:nth-child(1) > div:nth-child(2) > span > sup"
price_element = item.find_element(By.CSS_SELECTOR, price_css)
price_text = price_element.get_attribute('title').replace(',', '').replace('', '').strip()
if '-' in price_text:
min_price, max_price = map(int, price_text.split('-'))
else:
min_price = max_price = int(price_text)
item_prices.append((min_price, max_price))
# 미끼 상품 필터링 로직 적용
valid_items = []
base_prices = sorted([price[0] for price in item_prices])
for base_price in base_prices:
threshold = base_price * 1.5
valid_items = [price for price in item_prices if price[0] <= threshold]
if len(valid_items) > 1:
break
options_info[option_type_key]['valid_items'] = valid_items
return options_info
def modify_option_page(driver, product_info, translator, login_info):
simpleMode = login_info['whether_simpleMode']