네이버 안티봇 차단 우회 추가
parent
e53084ed17
commit
2107d5adf1
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue