# -*- coding: utf-8 -*- import sys; sys.path.insert(0, '.'); import wholesale_path from wholesale import SooinSession from bs4 import BeautifulSoup s = SooinSession() print('1. 로그인...') s.login() print('\n2. 장바구니 비우기...') s.clear_cart() print('\n3. Bag.asp 확인 (비우기 후)...') resp1 = s.session.get(f'{s.BAG_VIEW_URL}?currVenCd={s.vendor_code}', timeout=15) soup1 = BeautifulSoup(resp1.content, 'html.parser') int_array1 = soup1.find('input', {'name': 'intArray'}) print(f" intArray: {int_array1.get('value') if int_array1 else 'N/A'}") print('\n4. 코자정 검색...') result = s.search_products('코자정') product = result['items'][0] if result.get('items') else None print(f" 제품: {product['name']}, 코드: {product['internal_code']}") print('\n5. add_to_cart 호출...') cart_result = s.add_to_cart(product['internal_code'], qty=1, price=product['price'], stock=product['stock']) print(f" 결과: {cart_result}") print('\n6. Bag.asp 확인 (담기 후)...') resp2 = s.session.get(f'{s.BAG_VIEW_URL}?currVenCd={s.vendor_code}', timeout=15) soup2 = BeautifulSoup(resp2.content, 'html.parser') int_array2 = soup2.find('input', {'name': 'intArray'}) print(f" intArray: {int_array2.get('value') if int_array2 else 'N/A'}") # 품목 확인 import re rows = soup2.find_all('tr', id=re.compile(r'^bagLine')) print(f" 품목 수: {len(rows)}")