feat(lps): 봇 감지 시 IP 회전+재시도 + 감지 이력 기록
쿠팡이 봇으로 감지(Akamai 차단 페이지)하면, 같은 IP로 재시도하던 것을 '브라우저 끄고 새 IP로 켜서 재시도'로 전환. 감지 패턴도 축적한다. - DecodoProxy.rotate(): 시간창 무관 즉시 다음 포트(=새 IP). current_port 노출 - coupang/adapter: 0건+차단마커 감지 시 → 감지기록 → proxy.rotate()+강제재기동 → 인라인 재시도(max_block_retries=1). IP당 요청수(ip_request_no) 추적, 재기동 시 리셋 - bot_detection 테이블 + crud: source/query/ip_request_no/proxy_port/elapsed_sec/marker/ headless/html_len 기록 → 'IP당 몇 요청 만에 감지되나' 분석 가능 - worker_main: on_detect=BotDetectionLog.record 주입 - 로그: [coupang][BOT-DETECTED] ip_req#N port=... elapsed=...s marker=... - tests: proxy rotate 즉시회전 + 감지기록 CRUD → 전체 47/47 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
7911ba1745
commit
bca8032b79
7 files changed
+176
-29
No files matched your search
+8
-2
@@ -12,6 +12,7 @@ from common.logger import LOG
|
||||
from config.server_configs import web_server_config, openai_config
|
||||
from crud.job_crud import JobQueue
|
||||
from crud.negative_cache import NegativeCache
|
||||
from crud.bot_detection import BotDetectionLog
|
||||
from services.search.proxy import DecodoProxy
|
||||
from services.search.coupang.adapter import CoupangAdapter
|
||||
from services.search.naver.adapter import NaverAdapter
|
||||
@@ -29,8 +30,13 @@ async def main(concurrency: int = 1):
|
||||
# 쿠팡(브라우저, 무거움) + 네이버(오픈API, 가벼움) 동시 검색 → 병합 최저가
|
||||
# DECODO 프록시: .env 에 값 있으면 쿠팡만 sticky+주기적 회전으로 경유(없으면 직접 연결)
|
||||
proxy = DecodoProxy()
|
||||
LOG.i(f"DECODO 프록시: {'ON(sticky ' + str(proxy.session_minutes) + '분 회전)' if proxy.enabled else 'OFF(.env 미설정)'}")
|
||||
adapters = {"coupang": CoupangAdapter(headless=False, proxy=proxy), "naver": NaverAdapter()}
|
||||
LOG.i(f"DECODO 프록시: {'ON(sticky ' + str(proxy.session_minutes) + '분 회전)' if proxy.enabled else 'OFF(미설정)'}")
|
||||
# 봇 감지 시: 감지 기록(DB) + 새 IP 로 회전 후 재시도
|
||||
bot_log = BotDetectionLog()
|
||||
adapters = {
|
||||
"coupang": CoupangAdapter(headless=False, proxy=proxy, on_detect=bot_log.record),
|
||||
"naver": NaverAdapter(),
|
||||
}
|
||||
# OpenAI 키 있으면 '같은 상품' AI 판정 + 재검색어 생성 활성화
|
||||
has_openai = bool(openai_config.api_key)
|
||||
judge = SimilarityJudge() if has_openai else None
|
||||
|
||||
Reference in new issue
Block a user