website_audit 추출 정확도 개선 + Apify 빈값 방어
- website_parser: anchor-only href 추출로 CDN 노이즈 차단, additional_domains 를 data-lang/서브도메인 prefix 기반 글로벌 사이트 검출로 교체, main_cta 카테고리화 (전화/카톡/예약, fallback 제거) + 최대 3개 제한 - firecrawl: html → rawHtml 로 변경 (script 태그 보존 → 픽셀 검출 정상화) - gemini_vision: logo_colors_hex 최대 5개 → 2개 - branding: 기존 brandAssets 보존하면서 logo_* 머지 (collect_brand_basics 결과 덮어쓰지 않게) - facebook_audit: _page_patch 가 누락 필드 default 값으로 초기화 (Apify 가 페이지 데이터 못 받을 때 schema validation 실패 방어) - schemas: top_videos / bio / linked_domain 옵셔널 처리 (실제 누락 가능 케이스 대응) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
4ad30d4d36
commit
c4cbbaf7e7
9 files changed
+134
-63
No files matched your search
@@ -74,7 +74,7 @@ class FirecrawlClient:
|
||||
headers=self._headers(),
|
||||
json_body={
|
||||
"url": url,
|
||||
"formats": ["json", "links", "html"],
|
||||
"formats": ["json", "links", "rawHtml"],
|
||||
"jsonOptions": {
|
||||
"prompt": "Extract: clinic name (Korean), clinic name (English), address, phone with dash format, business hours, slogan, services offered, doctors with name/title/specialty, brand identity (primary/accent/background/text colors in hex, heading/body fonts, logo URL from the actual header/main <img> src, og:image from <meta property='og:image'> content, favicon URL)",
|
||||
"schema": {
|
||||
@@ -147,7 +147,7 @@ class FirecrawlClient:
|
||||
# "socialMedia": info.get("socialMedia", {}),
|
||||
"branding": info.get("branding", {}),
|
||||
"siteLinks": data.get("links", []),
|
||||
"html": data.get("html", ""), # raw HTML — collect 단계에서 tracking 추출 후 raw_data 에는 저장 안 함.
|
||||
"html": data.get("rawHtml", "") or data.get("html", ""), # rawHtml = 가공 전 원본 — <script> 등 보존.
|
||||
"sourceUrl": url,
|
||||
}
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ class VisionClient:
|
||||
' "logo_symbol": "심볼이 묘사하는 대상 (예: \'잎사귀\', \'추상 곡선\'). 없으면 빈 문자열",\n'
|
||||
' "logo_text": "로고에 보이는 워드마크 텍스트 그대로 (한글/영문). 없으면 빈 문자열",\n'
|
||||
' "logo_colors_desc": "로고에 쓰인 색감을 사람이 부르는 이름으로 서술 (예: \'딥네이비 + 골드\')",\n'
|
||||
' "logo_colors_hex": ["로고에서 시각적으로 두드러진 색 정확히 5개의 hex 근사값 배열. 예: [\'#1A2B3C\', \'#D4A017\', \'#FFFFFF\', \'#9E5C2A\', \'#1F1F1F\']. 강한 색이 5개 안 되면 음영/명도 차이로 5개 채울 것. 빈 배열 금지."]\n'
|
||||
' "logo_colors_hex": ["로고에서 시각적으로 가장 두드러진 색 최대 2개의 hex 근사값 배열. 예: [\'#1A2B3C\', \'#D4A017\']. 색이 1개면 1개만, 강한 색이 1개도 없으면 빈 배열."]\n'
|
||||
"}\n"
|
||||
"주의: logo_colors_hex 는 시각 추정이라 정확도 떨어질 수 있음. CSS 추출이 우선이고 이건 fallback/보완 용.\n"
|
||||
"모든 설명/텍스트 값은 반드시 한국어로 작성하세요 (영어 금지)."
|
||||
@@ -229,14 +229,9 @@ class VisionClient:
|
||||
return {}
|
||||
# logo_images는 우리가 직접 채움 (Vision은 묘사만)
|
||||
result["logo_images"] = {"circle": None, "horizontal": logo_url, "korean": None}
|
||||
# logo_colors_hex 5개 강제 정규화 — LLM 이 4개나 6개 줄 수도 있어서 길이 fallback.
|
||||
# logo_colors_hex 최대 2개로 제한.
|
||||
hex_list = [h for h in (result.get("logo_colors_hex") or []) if isinstance(h, str) and h.startswith("#")]
|
||||
if hex_list:
|
||||
while len(hex_list) < 5:
|
||||
hex_list.append(hex_list[-1]) # 마지막 색 복제로 패딩
|
||||
result["logo_colors_hex"] = hex_list[:5]
|
||||
else:
|
||||
result["logo_colors_hex"] = []
|
||||
result["logo_colors_hex"] = hex_list[:2]
|
||||
return result
|
||||
|
||||
async def describe_channel_logos(
|
||||
|
||||
@@ -134,7 +134,7 @@ class YouTubeAudit(BaseModel):
|
||||
channel_description: str
|
||||
linked_urls: list[LinkedUrl]
|
||||
playlists: list[str]
|
||||
top_videos: list[TopVideo]
|
||||
top_videos: list[TopVideo] = []
|
||||
diagnosis: list[DiagnosisItem]
|
||||
|
||||
|
||||
@@ -184,11 +184,11 @@ class FacebookPage(BaseModel):
|
||||
followers: int
|
||||
following: int
|
||||
category: str
|
||||
bio: str
|
||||
bio: str = ""
|
||||
logo: str
|
||||
logo_description: str
|
||||
link: str
|
||||
linked_domain: str
|
||||
linked_domain: str = ""
|
||||
reviews: int
|
||||
recent_post_age: str
|
||||
has_whatsapp: bool | None = None
|
||||
@@ -245,7 +245,7 @@ class AdditionalDomain(BaseModel):
|
||||
|
||||
class WebsiteAudit(BaseModel):
|
||||
primary_domain: str
|
||||
additional_domains: list[AdditionalDomain]
|
||||
additional_domains: list[AdditionalDomain] = []
|
||||
sns_links_on_site: bool
|
||||
sns_links_detail: list[SnsLink] | None = None
|
||||
tracking_pixels: list[TrackingPixel]
|
||||
|
||||
Reference in new issue
Block a user