From 2107d5adf1e616b2965d1a63ebac92cde5d5ca97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EA=B2=BD?= Date: Thu, 9 Jul 2026 15:04:10 +0900 Subject: [PATCH] =?UTF-8?q?=EB=84=A4=EC=9D=B4=EB=B2=84=20=EC=95=88?= =?UTF-8?q?=ED=8B=B0=EB=B4=87=20=EC=B0=A8=EB=8B=A8=20=EC=9A=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/utils/nvMapPwScraper.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/utils/nvMapPwScraper.py b/app/utils/nvMapPwScraper.py index 8e38d99..2b14814 100644 --- a/app/utils/nvMapPwScraper.py +++ b/app/utils/nvMapPwScraper.py @@ -52,6 +52,14 @@ class NvMapPwScraper(): cls._context = await cls._browser.new_context(**cls.default_context_builder()) cls.is_ready = True + @classmethod + async def _recreate_context(cls): + """네이버 안티봇 차단이 의심될 때 브라우저 컨텍스트를 새로 생성해 세션/핑거프린트를 초기화한다.""" + old_context = cls._context + cls._context = await cls._browser.new_context(**cls.default_context_builder()) + if old_context: + await old_context.close() + GRAPHQL_URL = "https://pcmap-api.place.naver.com/graphql" @classmethod @@ -436,5 +444,14 @@ patchedGetter.toString();''') if result: return result + # 1~3차 모두 실패 → 네이버 안티봇 차단 의심, 컨텍스트 재생성 후 원본 조건으로 1회 재시도 + logger.warning(f"[BLOCK-SUSPECTED] 3회 시도 모두 실패 → 컨텍스트 재생성 후 재시도: '{title}'") + await self.page.close() + await self._recreate_context() + await self.create_page() + result = await self._try_search(address, title) + if result: + return result + logger.error(f"[ERROR] Not found url for {selected}") return None