From 8604c6292db307a25fcc6cfd92137448c9b6966e Mon Sep 17 00:00:00 2001 From: gahusb Date: Fri, 1 May 2026 12:10:09 +0900 Subject: [PATCH] =?UTF-8?q?fix(agent-office):=20get=5Frunning=5Floop=20+?= =?UTF-8?q?=20pytrends=20timeout=20+=20UA=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - asyncio.get_event_loop() → asyncio.get_running_loop() (python 3.10+ 권장) - TrendReq에 timeout=(5, 15) 추가 (connect, read timeout) - User-Agent에서 'bot' 제거: 표준 Chrome UA로 변경 Co-Authored-By: Claude Sonnet 4.6 --- agent-office/app/youtube_researcher.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/agent-office/app/youtube_researcher.py b/agent-office/app/youtube_researcher.py index 1cf8639..eceb06f 100644 --- a/agent-office/app/youtube_researcher.py +++ b/agent-office/app/youtube_researcher.py @@ -82,7 +82,7 @@ async def fetch_google_trends(keywords: List[str], countries: List[str]) -> List def _sync_fetch(kw: str) -> List[Dict[str, Any]]: try: - pt = TrendReq(hl="en-US", tz=0) + pt = TrendReq(hl="en-US", tz=0, timeout=(5, 15)) pt.build_payload([kw], timeframe="now 7-d") df = pt.interest_over_time() if df.empty or kw not in df.columns: @@ -96,7 +96,7 @@ async def fetch_google_trends(keywords: List[str], countries: List[str]) -> List except Exception: return [] - loop = asyncio.get_event_loop() + loop = asyncio.get_running_loop() results = [] for kw in keywords[:5]: rows = await loop.run_in_executor(None, _sync_fetch, kw) @@ -109,7 +109,7 @@ async def fetch_billboard_top20() -> List[Dict[str, Any]]: """Billboard Hot 100 스크래핑 — 상위 20위.""" async with httpx.AsyncClient( timeout=10.0, - headers={"User-Agent": "Mozilla/5.0 (compatible; music-research-bot/1.0)"}, + headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"}, follow_redirects=True, ) as client: try: