- internal_code DB 저장 → 프론트에서 선택한 제품 그대로 주문 - 기존 장바구니 백업/복구로 사용자 장바구니 보존 - 수인약품 submit_order() 수정 (체크박스 제외 방식) - 테스트 파일 정리 및 문서 추가
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""submit_order 디버깅"""
|
|
import sys; sys.path.insert(0, '.'); import wholesale_path
|
|
from bs4 import BeautifulSoup
|
|
import re
|
|
|
|
import importlib
|
|
import wholesale.sooin
|
|
importlib.reload(wholesale.sooin)
|
|
from wholesale import SooinSession
|
|
|
|
SooinSession._instance = None
|
|
s = SooinSession()
|
|
s.login()
|
|
s.clear_cart()
|
|
|
|
# 품목 담기
|
|
r1 = s.search_products('코자정')
|
|
s.add_to_cart(r1['items'][0]['internal_code'], qty=1, price=r1['items'][0]['price'], stock=r1['items'][0]['stock'])
|
|
|
|
# 취소
|
|
s.cancel_item(row_index=0)
|
|
|
|
# Bag.asp GET
|
|
print('=== Bag.asp GET 후 form 분석 ===')
|
|
resp = s.session.get(f'{s.BAG_VIEW_URL}?currVenCd={s.vendor_code}', timeout=15)
|
|
soup = BeautifulSoup(resp.content, 'html.parser')
|
|
form = soup.find('form', {'id': 'frmBag'})
|
|
|
|
form_data = {}
|
|
for inp in form.find_all('input'):
|
|
name = inp.get('name', '')
|
|
if not name:
|
|
continue
|
|
|
|
inp_type = inp.get('type', 'text').lower()
|
|
|
|
if inp_type == 'checkbox':
|
|
checked = inp.get('checked')
|
|
print(f"체크박스 {name}: checked={checked}, type={type(checked)}")
|
|
|
|
if checked is not None:
|
|
form_data[name] = 'on'
|
|
print(f" → form_data['{name}'] = 'on' (취소됨, 제외)")
|
|
else:
|
|
print(f" → 안 보냄 (활성, 포함)")
|
|
continue
|
|
|
|
form_data[name] = inp.get('value', '')
|
|
|
|
print(f"\n체크박스 관련 form_data: {[(k,v) for k,v in form_data.items() if 'chk' in k]}")
|