- 恢复 kb-zhihu-metadata, kb-bilibili-metadata, kb-deep-analyzer - 修改 zhihu.py 和 analyze.py 使用 sys.path 方式导入 - 删除符号链接 kb_zhihu_metadata Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,13 @@ from typing import Dict, Any, Optional
|
||||
from datetime import datetime
|
||||
import re
|
||||
import asyncio
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add kb-zhihu-metadata to path for import
|
||||
_kb_zhihu_path = Path(__file__).parent.parent.parent / "kb-zhihu-metadata"
|
||||
if str(_kb_zhihu_path) not in sys.path:
|
||||
sys.path.insert(0, str(_kb_zhihu_path))
|
||||
|
||||
from kb_pipeline.platforms.base import PlatformAdapter
|
||||
from kb_pipeline.errors import AuthError
|
||||
@@ -20,7 +27,7 @@ from kb_pipeline.config import get_settings
|
||||
class ZhihuAdapter(PlatformAdapter):
|
||||
"""Zhihu platform adapter for answer and zhuanlan content extraction.
|
||||
|
||||
Uses ZhihuPlaywrightExtractor (from kb_zhihu_metadata) for content extraction.
|
||||
Uses ZhihuPlaywrightExtractor (from kb-zhihu-metadata) for content extraction.
|
||||
Requires KB_ZHIHU_COOKIE environment variable for authentication.
|
||||
|
||||
Example:
|
||||
@@ -82,14 +89,14 @@ class ZhihuAdapter(PlatformAdapter):
|
||||
def _get_extractor(self):
|
||||
"""Get or create ZhihuPlaywrightExtractor instance.
|
||||
|
||||
Lazy import to avoid dependency issues when kb_zhihu_metadata is not installed.
|
||||
Lazy import to avoid dependency issues when kb-zhihu-metadata is not installed.
|
||||
|
||||
Returns:
|
||||
ZhihuPlaywrightExtractor instance
|
||||
"""
|
||||
if self._extractor is None:
|
||||
try:
|
||||
from kb_zhihu_metadata.zhihu_extractor import ZhihuPlaywrightExtractor
|
||||
from zhihu_extractor import ZhihuPlaywrightExtractor
|
||||
self._extractor = ZhihuPlaywrightExtractor(
|
||||
headless=self.headless,
|
||||
timeout=self.timeout,
|
||||
@@ -97,8 +104,8 @@ class ZhihuAdapter(PlatformAdapter):
|
||||
)
|
||||
except ImportError as e:
|
||||
raise ImportError(
|
||||
"kb_zhihu_metadata package not found. "
|
||||
"Please install it to use ZhihuAdapter."
|
||||
"kb-zhihu-metadata module not found. "
|
||||
"Please ensure kb-zhihu-metadata directory exists."
|
||||
) from e
|
||||
return self._extractor
|
||||
|
||||
|
||||
Reference in New Issue
Block a user