# -*- coding: utf-8 -*- import sys import re sys.path.insert(0, r'c:\Users\청춘약국\source\pharmacy-pos-qr-system\backend') from sooin_api import SooinSession session = SooinSession() if session.login(): # 직접 요청해서 인코딩 확인 params = { 'so': '0', 'so2': '0', 'so3': '2', 'tx_physic': '073100220', 'tx_ven': '50911', 'currVenNm': '청춘약국' } resp = session.session.get(session.ORDER_URL, params=params, timeout=15) print('Content-Type:', resp.headers.get('Content-Type')) print('Encoding:', resp.encoding) print('Apparent Encoding:', resp.apparent_encoding) # charset 확인 charset_match = re.search(r'charset=([^\s;"]+)', resp.text[:1000]) print('HTML charset:', charset_match.group(1) if charset_match else 'Not found') # 직접 디코딩 테스트 print('\n--- 디코딩 테스트 ---') test_encodings = ['euc-kr', 'cp949', 'utf-8', 'iso-8859-1'] for enc in test_encodings: try: decoded = resp.content.decode(enc, errors='replace') # 코자정이 포함되어 있는지 확인 if '코자정' in decoded: print(f'{enc}: 성공! (코자정 발견)') elif '肄' in decoded or 'ㅺ' in decoded: print(f'{enc}: 부분 실패 (깨진 문자 발견)') else: print(f'{enc}: 확인 불가') except Exception as e: print(f'{enc}: 오류 - {e}')