- wholesale 패키지 연동 (SooinSession, GeoYoungSession) - Flask Blueprint 분리 (sooin_api.py, geoyoung_api.py) - order_context 스키마 확장 (wholesaler_id, internal_code 등) - 수인약품 개별 취소 기능 (cancel_item, restore_item) - 문서 추가: WHOLESALE_API_INTEGRATION.md - 테스트 스크립트들
91 lines
3.6 KiB
Python
91 lines
3.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""지오영 JavaScript에서 장바구니 추가 함수 찾기"""
|
|
|
|
import requests
|
|
from bs4 import BeautifulSoup
|
|
import asyncio
|
|
from playwright.async_api import async_playwright
|
|
import re
|
|
|
|
async def analyze_js():
|
|
async with async_playwright() as p:
|
|
browser = await p.chromium.launch(headless=True)
|
|
page = await browser.new_page()
|
|
|
|
# 로그인
|
|
await page.goto('https://gwn.geoweb.kr/Member/Login')
|
|
await page.fill('input[type="text"]', '7390')
|
|
await page.fill('input[type="password"]', 'trajet6640')
|
|
await page.click('button, input[type="submit"]')
|
|
await page.wait_for_load_state('networkidle')
|
|
|
|
# 메인 페이지
|
|
await page.goto('https://gwn.geoweb.kr/Home/Index')
|
|
await page.wait_for_timeout(3000)
|
|
|
|
# 모든 스크립트 태그 내용 가져오기
|
|
scripts = await page.evaluate('''() => {
|
|
var result = [];
|
|
var scripts = document.querySelectorAll('script');
|
|
scripts.forEach(s => {
|
|
if (s.src) {
|
|
result.push({type: 'src', url: s.src});
|
|
}
|
|
if (s.textContent && s.textContent.length > 100) {
|
|
result.push({type: 'inline', content: s.textContent});
|
|
}
|
|
});
|
|
return result;
|
|
}''')
|
|
|
|
print(f"스크립트 {len(scripts)}개 발견")
|
|
|
|
# 장바구니 관련 함수 찾기
|
|
for s in scripts:
|
|
if s['type'] == 'inline':
|
|
content = s['content']
|
|
# 담기, Cart, Add 관련 찾기
|
|
if '담기' in content or 'AddCart' in content or 'addCart' in content or 'InsertOrder' in content:
|
|
print("\n" + "="*60)
|
|
print("장바구니 관련 스크립트 발견!")
|
|
print("="*60)
|
|
|
|
# 함수 정의 찾기
|
|
func_patterns = [
|
|
r'function\s+(\w*[Cc]art\w*)\s*\([^)]*\)\s*{[^}]+}',
|
|
r'function\s+(\w*[Aa]dd\w*)\s*\([^)]*\)\s*{[^}]+}',
|
|
r'(\w+)\s*=\s*function\s*\([^)]*\)\s*{[^}]*[Cc]art[^}]*}',
|
|
]
|
|
|
|
for pattern in func_patterns:
|
|
matches = re.findall(pattern, content, re.DOTALL)
|
|
for m in matches:
|
|
print(f"함수 발견: {m}")
|
|
|
|
# ajax 호출 찾기
|
|
ajax_pattern = r'\$\.ajax\s*\(\s*{[^}]+url[^}]+}'
|
|
ajax_matches = re.findall(ajax_pattern, content, re.DOTALL)
|
|
for m in ajax_matches:
|
|
if 'cart' in m.lower() or 'order' in m.lower() or 'add' in m.lower():
|
|
print(f"\nAJAX 호출:\n{m[:500]}")
|
|
|
|
# 일부 내용 출력
|
|
lines = content.split('\n')
|
|
for i, line in enumerate(lines):
|
|
if '담기' in line or 'addCart' in line.lower() or 'insertorder' in line.lower():
|
|
print(f"\n관련 라인 {i}:")
|
|
print('\n'.join(lines[max(0,i-3):min(len(lines),i+10)]))
|
|
|
|
# 외부 JS 파일 확인
|
|
print("\n" + "="*60)
|
|
print("외부 스크립트 파일:")
|
|
print("="*60)
|
|
for s in scripts:
|
|
if s['type'] == 'src':
|
|
print(s['url'])
|
|
|
|
await browser.close()
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(analyze_js())
|