# -*- coding: utf-8 -*-
from sooin_api import SooinSession
import re

session = SooinSession()
session.login()

resp = session.session.get('http://sooinpharm.co.kr/Service/Order/Bag.asp?currVenCd=50911')
html = resp.text

# 모든 script 내용 출력
scripts = re.findall(r'<script[^>]*>(.*?)</script>', html, re.DOTALL)

for i, script in enumerate(scripts):
    # 삭제/취소 관련 있으면 출력
    if any(x in script.lower() for x in ['del', 'cancel', 'remove', 'chk_']):
        print(f'=== Script {i+1} ===')
        # 함수 시그니처만 추출
        funcs = re.findall(r'function\s+\w+[^{]+', script)
        for f in funcs[:5]:
            print(f'  {f.strip()}')
        
        # 특정 패턴 찾기
        patterns = re.findall(r'(delPhysic|cancelOrder|chkBag|selectDel)[^(]*\([^)]*\)', script)
        if patterns:
            print(f'  Patterns: {patterns[:5]}')
