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
@@ -1,4 +1,4 @@
|
||||
from sqlalchemy import Column, Index, SmallInteger, String, Text, DateTime
|
||||
from sqlalchemy import Boolean, Column, Index, Integer, SmallInteger, String, Text, DateTime
|
||||
from sqlalchemy.dialects.postgresql import UUID, JSONB
|
||||
from sqlalchemy.orm import declarative_base
|
||||
from sqlalchemy.sql import text
|
||||
@@ -66,3 +66,25 @@ class search_negative(MAIN_BASE):
|
||||
until = Column(DateTime(timezone=True), nullable=False) # 이 시각까지 not_found 로 간주
|
||||
reason = Column(String(200), nullable=True) # 종료 사유 메모(관측)
|
||||
created_at = Column(DateTime(timezone=True), nullable=False, server_default=text("now()"))
|
||||
|
||||
|
||||
class bot_detection(MAIN_BASE):
|
||||
"""봇 감지 이력 — '이 IP로 몇 번째 요청에서, 어떤 방식으로 차단됐나'를 축적해 패턴 분석.
|
||||
(예: SELECT avg(ip_request_no) → IP당 평균 몇 요청 만에 감지되는지)"""
|
||||
|
||||
@staticmethod
|
||||
def DBType():
|
||||
return DBType.MAIN.value
|
||||
|
||||
__tablename__ = "bot_detection"
|
||||
|
||||
id = Column(UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"))
|
||||
source = Column(String(20), nullable=False) # coupang 등
|
||||
query = Column(String(300), nullable=True) # 감지 당시 검색어
|
||||
ip_request_no = Column(Integer, nullable=True) # 현재 IP(브라우저)로 몇 번째 요청이었나
|
||||
proxy_port = Column(Integer, nullable=True) # 사용 중이던 프록시 포트(=IP 세션)
|
||||
elapsed_sec = Column(Integer, nullable=True) # 브라우저 실행 후 경과(초)
|
||||
marker = Column(String(120), nullable=True) # 감지 근거(차단 페이지 마커)
|
||||
headless = Column(Boolean, nullable=True)
|
||||
html_len = Column(Integer, nullable=True) # 응답 길이(차단 페이지는 작음)
|
||||
created_at = Column(DateTime(timezone=True), nullable=False, server_default=text("now()"))
|
||||
Reference in new issue
Block a user